Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Could-Computing
Assignment
## Assignment-2
Uses `DynamoDB` tables to store all Blackboard data.
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.327</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>


<dependencies>
<dependency>
Expand Down Expand Up @@ -64,6 +72,14 @@
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
</dependency>
</dependencies>
<properties>
<jersey.version>2.16</jersey.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

import java.util.List;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIgnore;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

@DynamoDBTable(tableName="courseTable")
public class Course {
private String courseID;
private String courseName;
Expand All @@ -19,7 +25,8 @@ public Course(String courseID, String courseName, String noOfCredits, String pro
this.noOfCredits = noOfCredits;
this.progID = progID;
}


@DynamoDBHashKey(attributeName="courseID")
public String getCourseID() {
return courseID;
}
Expand All @@ -28,6 +35,7 @@ public void setCourseID(String courseID) {
this.courseID = courseID;
}

@DynamoDBAttribute(attributeName="courseName")
public String getCourseName() {
return courseName;
}
Expand All @@ -36,6 +44,7 @@ public void setCourseName(String courseName) {
this.courseName = courseName;
}

@DynamoDBAttribute(attributeName="noOfCredits")
public String getNoOfCredits() {
return noOfCredits;
}
Expand All @@ -44,6 +53,7 @@ public void setNoOfCredits(String noOfCredits) {
this.noOfCredits = noOfCredits;
}

@DynamoDBAttribute(attributeName="program")
public List<String> getProgram() {
return program;
}
Expand All @@ -52,6 +62,7 @@ public void setProgram(List<String> program) {
this.program = program;
}

@DynamoDBAttribute(attributeName="progID")
public String getProgID() {
return progID;
}
Expand All @@ -60,14 +71,16 @@ public void setProgID(String progID) {
this.progID = progID;
}

@DynamoDBAttribute(attributeName="profID")
public String getProfID() {
return profID;
}

public void setProfID(String profID) {
this.profID = profID;
}


@DynamoDBIgnore
@Override
public String toString() {
return "CourseID" + getCourseID() + "CourseName" + getCourseName() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import java.util.ArrayList;
import java.util.List;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIgnore;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

@DynamoDBTable(tableName="deptTable")
public class Department {
private String deptID;
private String deptName;
Expand All @@ -20,36 +26,42 @@ public Department(String deptID, String deptName) {
this.programs = new ArrayList<String>();
this.professors = new ArrayList<String>();
}


@DynamoDBHashKey(attributeName="deptID")
public String getDeptID() {
return deptID;
}
public void setDeptID(String deprtID) {
this.deptID = deprtID;
}

@DynamoDBAttribute(attributeName="deptName")
public String getDeptName() {
return deptName;
}
public void setDeptName(String departName) {
this.deptName = departName;
}

@DynamoDBAttribute(attributeName="programs")
public List<String> getPrograms() {
return programs;
}

public void setPrograms(List<String> programs) {
this.programs = programs;
}


@DynamoDBAttribute(attributeName="professors")
public List<String> getProfessors() {
return professors;
}

public void setProfessors(List<String> professors) {
this.professors = professors;
}


@DynamoDBIgnore
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
Expand All @@ -60,5 +72,4 @@ public String toString() {
builder.append("\"}");
return builder.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.csye6225.fall2018.courseservice.Model;

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;

public class DynamoDbConnector {
static AmazonDynamoDB dynamoDb ;

public static void init() {
if (dynamoDb == null) {
// ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider();
// credentialsProvider.getCredentials();

dynamoDb = AmazonDynamoDBClientBuilder
.standard()
.withCredentials(DefaultAWSCredentialsProviderChain.getInstance())
.withRegion("us-west-2")
.build();
System.out.println("#### Created DDB client");
}

}

public AmazonDynamoDB getClient() {
return dynamoDb;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.csye6225.fall2018.courseservice.Model;
import javax.xml.bind.annotation.XmlRootElement;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIgnore;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

@DynamoDBTable(tableName="professorTable")
public class Professor {
private String firstName;
private String lastName;
Expand All @@ -19,46 +26,52 @@ public Professor(String profID, String firstName,
this.joiningDate = joiningDate;
}

@DynamoDBAttribute(attributeName="firstName")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}

@DynamoDBAttribute(attributeName="lastName")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

@DynamoDBAttribute(attributeName="deptID") // was DBAttribute changed to DBHashKey
public String getDeptID() {
return deptID;
}
public void setDeptID(String deptID) {
this.deptID = deptID;
}


@DynamoDBHashKey(attributeName="profID")
public String getProfID() {
return profID;
}
public void setProfID(String profID) {
this.profID = profID;
}

@DynamoDBAttribute(attributeName="joiningDate")
public String getJoiningDate() {
return joiningDate;
}
public void setJoiningDate(String joiningDate) {
this.joiningDate = joiningDate;
}

@DynamoDBIgnore
@Override
public String toString() {
return "ProfId=" + getProfID() + ", firstName=" + getFirstName()
+ ", deptID=" + getDeptID() + ", joiningDate=" + getJoiningDate();
}

public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import java.util.ArrayList;
import java.util.List;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIgnore;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

@DynamoDBTable(tableName="programTable")
public class Program {
private String programID;
private String programName;
Expand All @@ -20,6 +26,7 @@ public Program(String programID, String programName, String deptID) {
this.courses = new ArrayList<String>();
}

@DynamoDBHashKey(attributeName="progID")
public String getProgramID() {
return programID;
}
Expand All @@ -28,6 +35,7 @@ public void setProgramID(String programID) {
this.programID = programID;
}

@DynamoDBAttribute(attributeName="progName")
public String getProgramName() {
return programName;
}
Expand All @@ -36,22 +44,23 @@ public void setProgramName(String programName) {
this.programName = programName;
}

@DynamoDBAttribute(attributeName="courses")
public List<String> getCourses() {
return this.courses;
}
public void setCourses(List<String> courses) {
this.courses = courses;
}

@DynamoDBAttribute(attributeName="deptID")
public String getDeptID() {
return deptID;
}

public void setDeptID(String deptID) {
this.deptID = deptID;
}

public void setCourses(List<String> courses) {
this.courses = courses;
}

@DynamoDBIgnore
@Override
public String toString() {
return "ProgramID=" + getProgramID() + "ProgramName=" + getProgramName();
Expand Down
Loading