本文整理汇总了Java中org.ndexbio.model.object.NewUser类的典型用法代码示例。如果您正苦于以下问题:Java NewUser类的具体用法?Java NewUser怎么用?Java NewUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NewUser类属于org.ndexbio.model.object包,在下文中一共展示了NewUser类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestUser
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
private boolean createTestUser() {
try {
//localConnection.begin();
final NewUser newUser = new NewUser();
newUser.setEmailAddress("testUser");
newUser.setPassword("testUser");
newUser.setAccountName("testUser");
newUser.setFirstName("testUser");
newUser.setLastName("testUser");
testUser = dao.createNewUser(newUser,null);
//localConnection.commit();
return true;
} catch (Throwable e) {
return false;
}
}
示例2: compareObjectsContents
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
public static void compareObjectsContents(User user1, NewUser user2) {
assertEquals("account names do not match: ", user1.getUserName(), user2.getAccountName());
assertEquals("descriptions do not match: ", user1.getDescription(), user2.getDescription());
assertEquals("email addresses do not match: ", user1.getEmailAddress(), user2.getEmailAddress());
assertEquals("first names do not match: ", user1.getFirstName(), user2.getFirstName());
assertEquals("last names do not match: ", user1.getLastName(), user2.getLastName());
assertEquals("image URLs do not match: ", user1.getImage(), user2.getImage());
assertEquals("web sites do not match: ", user1.getWebsite(), user2.getWebsite());
return;
}
示例3: updateMembershipAddMember
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
@Test
public void updateMembershipAddMember() throws ObjectNotFoundException, NdexException {
User member = null;
try {
//localConnection.begin();
final NewUser newUser = new NewUser();
newUser.setEmailAddress("member");
newUser.setPassword("member");
newUser.setAccountName("member");
newUser.setFirstName("member");
newUser.setLastName("member");
member = userDAO.createNewUser(newUser,null);
//localConnection.commit();
Membership membership = new Membership();
membership.setMemberAccountName(member.getAccountName());
membership.setMemberUUID(member.getExternalId());
membership.setPermissions(Permissions.WRITE);
membership.setMembershipType(MembershipType.GROUP);
dao.updateMember(membership, testGroup.getExternalId(), testUser.getExternalId());
//localConnection.commit();
} catch(Exception e) {
fail(e.getMessage());
} finally {
userDAO.deleteUserById(member.getExternalId());
//localConnection.commit();
}
}
示例4: createUserInvalidAccountName
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void createUserInvalidAccountName() throws NdexException, IllegalArgumentException {
final NewUser newUser = new NewUser();
newUser.setEmailAddress("test");
newUser.setPassword("test");
newUser.setAccountName("");
newUser.setFirstName("test");
newUser.setLastName("test");
dao.createNewUser(newUser,null);
}
示例5: createUserInvalidPassword
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void createUserInvalidPassword() throws NdexException, IllegalArgumentException {
final NewUser newUser = new NewUser();
newUser.setEmailAddress("test");
newUser.setPassword("");
newUser.setAccountName("test");
newUser.setFirstName("test");
newUser.setLastName("test");
dao.createNewUser(newUser,null);
}
示例6: createUserInvalidEmail
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void createUserInvalidEmail() throws NdexException, IllegalArgumentException {
final NewUser newUser = new NewUser();
newUser.setEmailAddress("");
newUser.setPassword("test");
newUser.setAccountName("test");
newUser.setFirstName("test");
newUser.setLastName("test");
dao.createNewUser(newUser,null);
}
示例7: createUserExistingUser
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
@Test(expected = DuplicateObjectException.class)
public void createUserExistingUser() throws IllegalArgumentException, NdexException, DuplicateObjectException {
final NewUser newUser = new NewUser();
newUser.setEmailAddress("test");
newUser.setPassword("test");
newUser.setAccountName("test");
newUser.setFirstName("test");
newUser.setLastName("test");
dao.createNewUser(newUser,null);
}
示例8: createNewUser
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
/**************************************************************************
* Create a new user
*
* @param newUser
* A User object, from the NDEx Object Model
* @throws NdexException
* Attempting to save an ODocument to the database
* @throws IllegalArgumentException
* The newUser does not contain proper fields
* @throws DuplicateObjectException
* The account name and/or email already exist
* @returns User object, from the NDEx Object Model
**************************************************************************/
public User createNewUser(NewUser newUser, String verificationCode ) throws NdexException,
IllegalArgumentException, DuplicateObjectException {
Preconditions.checkArgument(null != newUser,
"A user object is required");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(newUser.getAccountName()),
"A accountName is required");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(newUser.getPassword()),
"A user password is required");
Preconditions.checkArgument(
!Strings.isNullOrEmpty(newUser.getEmailAddress()),
"A user email address is required");
this.checkForExistingUser(newUser);
try {
ODocument user = new ODocument(NdexClasses.User).
fields("description", newUser.getDescription(),
"websiteURL", newUser.getWebsite(),
"imageURL", newUser.getImage(),
"emailAddress", newUser.getEmailAddress(),
"firstName", newUser.getFirstName(),
"lastName", newUser.getLastName(),
//, newUser.getAccountName(),
"password", Security.hashText(newUser.getPassword()),
NdexClasses.ExternalObj_ID, NdexUUIDFactory.INSTANCE.createNewNDExUUID(),
NdexClasses.ExternalObj_cTime, new Date(),
NdexClasses.ExternalObj_mTime, new Date()
//NdexClasses.ExternalObj_isDeleted, false
);
if ( verificationCode !=null) {
// String verCode= Security.generatePassword(10);
user.fields(NdexClasses.User_verification_code, verificationCode,
NdexClasses.ExternalObj_isDeleted, true,
NdexClasses.account_P_oldAcctName, newUser.getAccountName());
} else {
user.fields(NdexClasses.ExternalObj_isDeleted, false,
NdexClasses.account_P_accountName, newUser.getAccountName());
}
user = user.save();
logger.info("A new user with accountName "
+ newUser.getAccountName() + " has been created");
User u = UserDocDAO.getUserFromDocument(user);
// if ( needEmailVerification)
// u.set
return u;
} catch (Exception e) {
logger.severe("Could not save new user to the database: " + e.getMessage());
throw new NdexException(e.getMessage());
}
}
示例9: createTestUser
import org.ndexbio.model.object.NewUser; //导入依赖的package包/类
private void createTestUser() {
try {
final NewUser newUser = new NewUser();
newUser.setEmailAddress("testUser");
newUser.setPassword("testUser");
newUser.setAccountName("testUser");
newUser.setFirstName("testUser");
newUser.setLastName("testUser");
testUser = userDAO.createNewUser(newUser,null);
//localConnection.commit();
//return true;
} catch (Throwable e) {
fail(e.getMessage());
}
}