-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Initial commit * Add verification script * Finalise changes before test * Update logs * Add ; * Finish course migration * Verified Results * Fix lint * Fix lint * Change isMigrationNeeded to always return true
- Loading branch information
Showing
7 changed files
with
159 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/client/java/teammates/client/scripts/sql/DataMigrationForCourseSql.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package teammates.client.scripts.sql; | ||
|
||
import com.googlecode.objectify.cmd.Query; | ||
|
||
import teammates.storage.entity.Course; | ||
|
||
/** | ||
* Data migration class for course entity. | ||
*/ | ||
@SuppressWarnings("PMD") | ||
public class DataMigrationForCourseSql extends | ||
DataMigrationEntitiesBaseScriptSql<teammates.storage.entity.Course, teammates.storage.sqlentity.Course> { | ||
|
||
public static void main(String[] args) { | ||
new DataMigrationForCourseSql().doOperationRemotely(); | ||
} | ||
|
||
@Override | ||
protected Query<Course> getFilterQuery() { | ||
return ofy().load().type(teammates.storage.entity.Course.class); | ||
} | ||
|
||
@Override | ||
protected boolean isPreview() { | ||
return false; | ||
} | ||
|
||
/* | ||
* Sets the migration criteria used in isMigrationNeeded. | ||
*/ | ||
@Override | ||
protected void setMigrationCriteria() { | ||
// No migration criteria currently needed. | ||
} | ||
|
||
@Override | ||
protected boolean isMigrationNeeded(Course entity) { | ||
// HibernateUtil.beginTransaction(); | ||
// teammates.storage.sqlentity.Course course = HibernateUtil.get( | ||
// teammates.storage.sqlentity.Course.class, entity.getUniqueId()); | ||
// HibernateUtil.commitTransaction(); | ||
// return course == null; | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void migrateEntity(Course oldCourse) throws Exception { | ||
teammates.storage.sqlentity.Course newCourse = new teammates.storage.sqlentity.Course( | ||
oldCourse.getUniqueId(), | ||
oldCourse.getName(), | ||
oldCourse.getTimeZone(), | ||
oldCourse.getInstitute()); | ||
// newCourse.setCreatedAt(oldCourse.getCreatedAt()); | ||
newCourse.setDeletedAt(oldCourse.getDeletedAt()); | ||
saveEntityDeferred(newCourse); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/client/java/teammates/client/scripts/sql/VerifyCourseAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package teammates.client.scripts.sql; | ||
|
||
import teammates.storage.entity.Course; | ||
|
||
/** | ||
* Class for verifying account attributes. | ||
*/ | ||
@SuppressWarnings("PMD") | ||
public class VerifyCourseAttributes | ||
extends VerifyNonCourseEntityAttributesBaseScript<Course, teammates.storage.sqlentity.Course> { | ||
|
||
public VerifyCourseAttributes() { | ||
super(Course.class, | ||
teammates.storage.sqlentity.Course.class); | ||
} | ||
|
||
@Override | ||
protected String generateID(teammates.storage.sqlentity.Course sqlEntity) { | ||
return sqlEntity.getId(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
VerifyCourseAttributes script = new VerifyCourseAttributes(); | ||
script.doOperationRemotely(); | ||
} | ||
|
||
// Used for sql data migration | ||
@Override | ||
public boolean equals(teammates.storage.sqlentity.Course sqlEntity, Course datastoreEntity) { | ||
try { | ||
return sqlEntity.getId().equals(datastoreEntity.getUniqueId()) | ||
&& sqlEntity.getName().equals(datastoreEntity.getName()) | ||
&& sqlEntity.getTimeZone().equals(datastoreEntity.getTimeZone()) | ||
&& sqlEntity.getInstitute().equals(datastoreEntity.getInstitute()) | ||
// && sqlEntity.getCreatedAt().equals(datastoreEntity.getCreatedAt()) | ||
&& datastoreEntity.getDeletedAt() == null ? sqlEntity.getDeletedAt() == null | ||
: sqlEntity.getDeletedAt().equals(datastoreEntity.getDeletedAt()); | ||
} catch (IllegalArgumentException iae) { | ||
return false; | ||
} | ||
} | ||
} |