Search in sources :

Example 6 with Account

use of teammates.storage.entity.Account in project teammates by TEAMMATES.

the class AccountAttributesTest method testValueOf.

@Test
public void testValueOf() {
    Account genericAccount = new Account("id", "Joe", true, "joe@example.com", "Teammates Institute");
    AccountAttributes observedAccountAttributes = AccountAttributes.valueOf(genericAccount);
    assertEquals(genericAccount.getGoogleId(), observedAccountAttributes.getGoogleId());
    assertEquals(genericAccount.getName(), observedAccountAttributes.getName());
    assertEquals(genericAccount.isInstructor(), observedAccountAttributes.isInstructor());
    assertEquals(genericAccount.getEmail(), observedAccountAttributes.getEmail());
    assertEquals(genericAccount.getInstitute(), observedAccountAttributes.getInstitute());
    assertEquals(genericAccount.getCreatedAt(), observedAccountAttributes.createdAt);
    assertEquals(genericAccount.getStudentProfile(), observedAccountAttributes.studentProfile);
}
Also used : Account(teammates.storage.entity.Account) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) Test(org.testng.annotations.Test)

Example 7 with Account

use of teammates.storage.entity.Account in project teammates by TEAMMATES.

the class AccountsDb method deleteAccount.

/**
 * Note: This is a non-cascade delete. <br>
 *   <br> Fails silently if there is no such account.
 * <br> Preconditions:
 * <br> * {@code googleId} is not null.
 */
public void deleteAccount(String googleId) {
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, googleId);
    Account accountToDelete = getAccountEntity(googleId, true);
    if (accountToDelete == null) {
        return;
    }
    StudentProfile studentProfile = accountToDelete.getStudentProfile();
    if (studentProfile != null) {
        BlobKey pictureKey = studentProfile.getPictureKey();
        if (!pictureKey.getKeyString().isEmpty()) {
            deletePicture(pictureKey);
        }
        profilesDb.deleteEntityDirect(studentProfile);
    }
    deleteEntityDirect(accountToDelete);
}
Also used : StudentProfile(teammates.storage.entity.StudentProfile) Account(teammates.storage.entity.Account) BlobKey(com.google.appengine.api.blobstore.BlobKey)

Example 8 with Account

use of teammates.storage.entity.Account in project teammates by TEAMMATES.

the class AccountsDb method getAccountEntity.

private Account getAccountEntity(String googleId, boolean retrieveStudentProfile) {
    Account account = load().id(googleId).now();
    if (account == null) {
        return null;
    }
    account.setIsStudentProfileEnabled(retrieveStudentProfile);
    return account;
}
Also used : Account(teammates.storage.entity.Account)

Aggregations

Account (teammates.storage.entity.Account)8 StudentProfile (teammates.storage.entity.StudentProfile)4 Test (org.testng.annotations.Test)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 BlobKey (com.google.appengine.api.blobstore.BlobKey)1 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 InvalidParametersException (teammates.common.exception.InvalidParametersException)1 ProfilesDb (teammates.storage.api.ProfilesDb)1