本文整理汇总了Java中org.javarosa.core.model.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.javarosa.core.model包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: userExists
import org.javarosa.core.model.User; //导入依赖的package包/类
private boolean userExists(String username) {
int attempts = 0;
//An absurd number of tries
while(attempts < 50) {
try{
IStorageIterator iterator = StorageManager.getStorage(User.STORAGE_KEY).iterate();
while(iterator.hasMore()) {
User u = (User)iterator.nextRecord();
if(username.toLowerCase().equals(u.getUsername().toLowerCase())) {
return true;
}
}
return false;
}
catch(StorageModifiedException sme) {
//storage modified while we were going through users. Try again
attempts++;
}
}
//Dunno what to do here, really, it would be crazy to gt to this point.
//Maybe should throw an exception, actually.
Logger.log("restore", "Could not look through User list to determine if user " + username + " exists.");
return false;
}
示例2: editUsers
import org.javarosa.core.model.User; //导入依赖的package包/类
public void editUsers() {
//2012-10-22 - ctsims - Disabling this for now unless you're in completely offline user mode.
//There's no way to do it without an intermediate authentication otherwise.
if(CommCareProperties.USER_REG_SKIP.equals(PropertyManager._().getSingularProperty(CommCareProperties.USER_REG_TYPE))) {
J2MEDisplay.startStateWithLoadingScreen(new CommCareSelectState<User>(new UserEntity(), User.STORAGE_KEY) {
public void cancel() {
CommCareUtil.launchHomeState();
}
public void entitySelected(int id) {
User u = (User)StorageManager.getStorage(User.STORAGE_KEY).read(id);
J2MEDisplay.startStateWithLoadingScreen(new CommCareEditUserState(u,
!CommCareProperties.USER_REG_SKIP.equals(PropertyManager._().getSingularProperty(CommCareProperties.USER_REG_TYPE)),
PropertyManager._().getSingularProperty(JavaRosaPropertyRules.OPENROSA_API_LEVEL)));
}
});
} else {
J2MEDisplay.showError("Can't edit users", "User edit is disabled when using a server. Please edit the user online.");
}
}
示例3: start
import org.javarosa.core.model.User; //导入依赖的package包/类
public void start() {
User u = CommCareContext._().getUser();
//Don't even trigger the sync stuff if we're logged in as a magic user
//("admin" or the demo user).
if(CommCareUtil.isMagicAdmin(u)) {
onSuccess(Localization.get("sync.pull.admin"));
return;
}
else if(User.DEMO_USER.equals(u.getUserType())) {
onSuccess(Localization.get("sync.pull.demo"));
return;
}
//This involves the global context, and thus should really be occurring in the constructor, but
//also takes a long time, and thus is more important to not occur until starting.
CommCareContext._().purgeScheduler(true);
send.start();
}
示例4: upgradeSevenEight
import org.javarosa.core.model.User; //导入依赖的package包/类
/**
* Depcrecate the old AUser object so that both platforms are using the User object
* to represents users
*/
private boolean upgradeSevenEight(SQLiteDatabase db) {
long start = System.currentTimeMillis();
db.beginTransaction();
try {
SqlStorage<Persistable> userStorage = new SqlStorage<Persistable>(AUser.STORAGE_KEY, AUser.class, new ConcreteAndroidDbHelper(c, db));
SqlStorageIterator<Persistable> iterator = userStorage.iterate();
while (iterator.hasMore()) {
AUser oldUser = (AUser)iterator.next();
User newUser = oldUser.toNewUser();
userStorage.write(newUser);
}
db.setTransactionSuccessful();
return true;
} finally {
db.endTransaction();
Log.d(TAG, "Case model update complete in " + (System.currentTimeMillis() - start) + "ms");
}
}
示例5: syncDataForLoggedInUser
import org.javarosa.core.model.User; //导入依赖的package包/类
public void syncDataForLoggedInUser(final SyncCapableCommCareActivity activity,
final boolean formsToSend, final boolean userTriggeredSync) {
User u = CommCareApplication.instance().getSession().getLoggedInUser();
if (User.TYPE_DEMO.equals(u.getUserType())) {
if (userTriggeredSync) {
// Remind the user that there's no syncing in demo mode.
if (formsToSend) {
activity.handleSyncNotAttempted(Localization.get("main.sync.demo.has.forms"));
} else {
activity.handleSyncNotAttempted(Localization.get("main.sync.demo.no.forms"));
}
}
return;
}
SharedPreferences prefs = CommCareApplication.instance().getCurrentApp().getAppPreferences();
syncData(activity, formsToSend, userTriggeredSync, ServerUrls.getDataServerKey(),
u.getUsername(), u.getCachedPwd(), u.getUniqueId());
}
示例6: setupFixtureData
import org.javarosa.core.model.User; //导入依赖的package包/类
protected AbstractTreeElement setupFixtureData(ExternalDataInstance instance) {
String ref = instance.getReference();
String userId = "";
User u = mSandbox.getLoggedInUser();
if (u != null) {
userId = u.getUniqueId();
}
AbstractTreeElement indexedFixture =
IndexedFixtureInstanceTreeElement.get(mSandbox, getRefId(ref), instance.getBase());
if (indexedFixture != null) {
return indexedFixture;
} else {
return loadFixtureRoot(instance, ref, userId);
}
}
示例7: writeNewUser
import org.javarosa.core.model.User; //导入依赖的package包/类
private void writeNewUser(UserKeyRecord keyRecord) {
SQLiteDatabase userDatabase = null;
try {
userDatabase = new DatabaseUserOpenHelper(CommCareApplication.instance(),
keyRecord.getUuid()).getWritableDatabase(UserSandboxUtils.getSqlCipherEncodedKey(randomKey));
User user = new User(username, passwordHash, username, userType);
SqlStorage<User> userStorage =
new SqlStorage<>(User.STORAGE_KEY, User.class, new ConcreteAndroidDbHelper(context, userDatabase));
userStorage.write(user);
} finally {
if (userDatabase != null) {
userDatabase.close();
}
}
}
示例8: _commandAction
import org.javarosa.core.model.User; //导入依赖的package包/类
public void _commandAction(Command c, Displayable d) {
if(c.equals(CMD_SAVE)) {
UserValidator validator = new UserValidator(view);
int status = validator.validateNewUser();
if(status == UserValidator.OK) {
User u = validator.constructUser();
//Don't add the user to the RMS yet, that's for the receiver.
transitions.userCreated(u);
} else {
validator.handleInvalidUser(status, this);
}
} else if(c.equals(CMD_CANCEL)) {
transitions.cancel();
}
}
示例9: readResponse
import org.javarosa.core.model.User; //导入依赖的package包/类
public User readResponse(SimpleHttpTransportMessage message) throws UnrecognizedResponseException {
this.prompt = null;
byte[] responseBody = message.getResponseBody();
//Not actually a response
if(responseBody == null) {
throw new UnrecognizedResponseException("No response body");
}
String responseVersion = message.getResponseProperties().getORApiVersion();
if(responseVersion == null) {
//If there's no version from the server, assume it's the same as the
//sent version
responseVersion = orApiVersion;
}
Document doc = CommUtil.getXMLResponse(responseBody);
if (doc == null) {
throw new UnrecognizedResponseException("can't parse xml");
}
return readResponseDocument(doc);
}
示例10: testAccessorsModifiers
import org.javarosa.core.model.User; //导入依赖的package包/类
public void testAccessorsModifiers () {
User u = new User();
u.setUserType("ADMIN");
if (!u.getUserType().equals("ADMIN")) {
fail("UserType getter/setter broken");
}
u.setUsername("TEST");
if (!u.getUsername().equals("TEST")) {
fail("Username getter/setter broken");
}
u.setPassword("TEST");
if (!u.getPasswordHash().equals("TEST")) {
fail("Password getter/setter broken");
}
u.setID(1);
if (u.getID() != 1) {
fail("RecordId getter/setter broken");
}
}
示例11: writeUserReport
import org.javarosa.core.model.User; //导入依赖的package包/类
private void writeUserReport(XmlSerializer serializer, Vector errors) throws IllegalArgumentException, IllegalStateException, IOException {
IStorageUtility<User> userStorage = StorageManager.getStorage(User.STORAGE_KEY);
serializer.startTag(XMLNS, "user_subreport");
try{
for(IStorageIterator<User> it = userStorage.iterate(); it.hasMore();) {
User u = it.nextRecord();
try {
writeUser(serializer, errors, u);
} catch(Exception e) {
logError(errors, new StatusReportException(e,"user_subreport","Error writing user : " + u.getUsername() + "|" + u.getUniqueId()));
}
}
} finally {
serializer.endTag(XMLNS, "user_subreport");
}
}
示例12: setupFixtureData
import org.javarosa.core.model.User; //导入依赖的package包/类
protected AbstractTreeElement setupFixtureData(ExternalDataInstance instance) {
String ref = instance.getReference();
//TODO: This is all just copied from J2ME code. that's pretty silly. unify that.
String userId = "";
User u = mSandbox.getLoggedInUser();
if (u != null) {
userId = u.getUniqueId();
}
String refId = ref.substring(ref.lastIndexOf('/') + 1, ref.length());
try {
FormInstance fixture = SandboxUtils.loadFixture(mSandbox, refId, userId);
if (fixture == null) {
throw new FixtureInitializationException("Could not find an lookup table for src: " + ref);
}
TreeElement root = fixture.getRoot();
root.setParent(instance.getBase());
return root;
} catch (IllegalStateException ise) {
throw new FixtureInitializationException("Could not load fixture for src: " + ref);
}
}
示例13: login
import org.javarosa.core.model.User; //导入依赖的package包/类
public void login() {
J2MEDisplay.startStateWithLoadingScreen(new CommCareLoginState() {
public void loggedIn(User u, String password) {
//If they logged in as an admin user, we can assume they don't need the first start screen anymore.
if(!(u.getUserType().equals(User.DEMO_USER))) {
PropertyManager._().setProperty(CommCareProperties.IS_FIRST_RUN, CommCareProperties.PROPERTY_NO);
}
super.loggedIn(u, password);
}
});
}
示例14: start
import org.javarosa.core.model.User; //导入依赖的package包/类
public void start() {
if (interactive) {
super.start();
} else {
User u = getLoggedInUser();
loggedIn(u, u.getPasswordHash());
}
}
示例15: clearUserData
import org.javarosa.core.model.User; //导入依赖的package包/类
private void clearUserData() {
StorageManager.getStorage(User.STORAGE_KEY).removeAll(new EntityFilter<User>() {
public boolean matches(User e) {
if(e.isAdminUser()) { return false;}
return true;
}
});
StorageManager.getStorage(Case.STORAGE_KEY).removeAll();
}