本文整理汇总了Java中org.javarosa.core.services.storage.StorageManager类的典型用法代码示例。如果您正苦于以下问题:Java StorageManager类的具体用法?Java StorageManager怎么用?Java StorageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StorageManager类属于org.javarosa.core.services.storage包,在下文中一共展示了StorageManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markTriggered
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public static void markTriggered(PeriodicEvent event) {
//For events which can be triggered manually (outside of the framework), and want to have their occurances updated.
PeriodicEventRecord record = null;
IStorageUtilityIndexed storage = (IStorageUtilityIndexed)StorageManager.getStorage(PeriodicEventRecord.STORAGE_KEY);
try {
record = (PeriodicEventRecord)storage.getRecordForValue(PeriodicEventRecord.META_EVENT_KEY, event.getEventKey());
} catch(NoSuchElementException nsee) {
//No record. Any scheduled events would have one, so don't sweat it and just get outta here.
System.out.println("No initialized records of type: " + event.getEventKey() + ". Skipping scheduling");
return;
}
PeriodicEventRecord nextTrigger = event.scheduleNextTrigger(record);
storage.write(nextTrigger);
System.out.println("Event[" + event.getEventKey() + "] manually triggered. Next Execution due at " + DateUtils.formatDate(nextTrigger.getNextTrigger(), DateUtils.FORMAT_HUMAN_READABLE_SHORT));
}
示例2: PeriodicWrapperState
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
/**
* Creates a wrapper state ready for execution.
*
* @param descriptors All of the periodic events defined in the
* current environment.
*/
public PeriodicWrapperState(PeriodicEvent[] descriptors) {
now = new Date();
d = new Hashtable<String, PeriodicEvent>();
for(PeriodicEvent e : descriptors) {
d.put(e.getEventKey(), e);
}
storage = StorageManager.getStorage(PeriodicEventRecord.STORAGE_KEY);
toCheck = new Stack<Integer>();
for(IStorageIterator i = storage.iterate(); i.hasMore(); ) {
toCheck.addElement(DataUtil.integer(i.nextID()));
}
}
示例3: userExists
import org.javarosa.core.services.storage.StorageManager; //导入依赖的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;
}
示例4: getLoggedInUser
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
protected static User getLoggedInUser() {
IStorageUtilityIndexed users = (IStorageUtilityIndexed)StorageManager.getStorage(User.STORAGE_KEY);
if(CommCareSense.isAutoLoginEnabled()) {
User user = (User)users.getRecordForValue(User.META_UID, PropertyManager._().getSingularProperty(CommCareProperties.LOGGED_IN_USER));
return user;
}
IStorageIterator ui = users.iterate();
User admin = null;
while (ui.hasMore()) {
User u = (User)ui.nextRecord();
if (u.isAdminUser()) {
admin = u;
} else {
return u;
}
}
return admin;
}
示例5: editUsers
import org.javarosa.core.services.storage.StorageManager; //导入依赖的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.");
}
}
示例6: toggleDemoMode
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public void toggleDemoMode(boolean demoOn) {
if (demoOn != inDemoMode) {
CommCareUtil.cycleDemoStyles(demoOn);
inDemoMode = demoOn;
if (demoOn) {
registerDemoStorage(Case.STORAGE_KEY, Case.class);
registerDemoStorage(FormInstance.STORAGE_KEY, FormInstance.class);
registerWrappedDemoStorage(TransportMessageStore.Q_STORENAME, new TransportMessageSerializationWrapper());
registerWrappedDemoStorage(TransportMessageStore.RECENTLY_SENT_STORENAME, new TransportMessageSerializationWrapper());
TransportService.reinit();
} else {
StorageManager.registerStorage(Case.STORAGE_KEY, Case.class);
StorageManager.registerStorage(FormInstance.STORAGE_KEY, FormInstance.class);
StorageManager.registerWrappedStorage(TransportMessageStore.Q_STORENAME, TransportMessageStore.Q_STORENAME, new TransportMessageSerializationWrapper());
StorageManager.registerWrappedStorage(TransportMessageStore.RECENTLY_SENT_STORENAME, TransportMessageStore.RECENTLY_SENT_STORENAME, new TransportMessageSerializationWrapper());
TransportService.reinit();
}
}
}
示例7: autoPurge
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public Hashtable<String, Hashtable<Integer, String>> autoPurge () {
Hashtable<String, Hashtable<Integer, String>> deletedLog = new Hashtable<String, Hashtable<Integer, String>>();
//attempt to purge different types of objects in such an order that, if interrupted, we'll avoid referential integrity errors
//1) tx queue is self-managing
//do nothing
//3) cases (delete cases that are closed AND have no open cases which index them)
purgeRMS(Case.STORAGE_KEY, caseFilter(), deletedLog);
//4) Ledger models (ledger database objects with no matching case)
purgeRMS(Ledger.STORAGE_KEY, new LedgerPurgeFilter((IStorageUtilityIndexed)StorageManager.getStorage(Ledger.STORAGE_KEY),
(IStorageUtilityIndexed)StorageManager.getStorage(Case.STORAGE_KEY)), deletedLog);
//5) reclog will never grow that large in size
//do nothing
//6) incident log is (mostly) self-managing
//do nothing
return deletedLog;
}
示例8: purgeRMS
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
private void purgeRMS (String key, EntityFilter filt, Hashtable<String, Hashtable<Integer, String>> deletedLog) {
RMSStorageUtility rms = (RMSStorageUtility)StorageManager.getStorage(key);
//TODO: Reimplement the printout here.
//Hashtable<Integer, RMSRecordLoc> index = rms.getIDIndexRecord();
Vector<Integer> deletedIDs = rms.removeAll(filt);
Hashtable<Integer, String> deletedDetail = new Hashtable<Integer, String>();
for (int i = 0; i < deletedIDs.size(); i++) {
int id = deletedIDs.elementAt(i).intValue();
//RMSRecordLoc detail = index.get(new Integer(id));
RMSRecordLoc detail = null;
deletedDetail.put(new Integer(id), detail != null ? "(" + detail.rmsID + "," + detail.recID + ")" : "?");
}
deletedLog.put(key, deletedDetail);
}
示例9: CreateTemporaryResourceTable
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public static ResourceTable CreateTemporaryResourceTable(String name) {
ResourceTable table = new ResourceTable();
IStorageUtilityIndexed storage = null;
String storageKey = STORAGE_KEY_TEMPORARY + name.toUpperCase();
//Check if this table already exists, and return it if so.
for(String utilityName : StorageManager.listRegisteredUtilities()) {
if(utilityName.equals(storageKey)) {
table = ResourceTable.RetrieveTable((IStorageUtilityIndexed)StorageManager.getStorage(storageKey));
}
}
//Otherwise, create a new one.
if(storage == null) {
StorageManager.registerStorage(storageKey, storageKey, Resource.class);
table = ResourceTable.RetrieveTable((IStorageUtilityIndexed)StorageManager.getStorage(storageKey));
}
return table;
}
示例10: registerModule
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public void registerModule() {
String[] prototypes = new String[] {BasicInstaller.class.getName(),
LocaleFileInstaller.class.getName(),
SuiteInstaller.class.getName(),
ProfileInstaller.class.getName(),
MediaInstaller.class.getName(),
XFormInstaller.class.getName(),
Text.class.getName(),
PropertySetter.class.getName(),
FormEntry.class.getName(),
DummyGraphDetailTemplate.class.getName()};
PrototypeManager.registerPrototypes(prototypes);
StorageManager.registerStorage(CommCareContext.STORAGE_TABLE_GLOBAL, Resource.class);
StorageManager.registerStorage(Suite.STORAGE_KEY, Suite.class);
StorageManager.registerStorage(Profile.STORAGE_KEY, Profile.class);
}
示例11: validateHouseholdID
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public boolean validateHouseholdID (String hhid) {
IStorageUtilityIndexed cases = (IStorageUtilityIndexed)StorageManager.getStorage(Case.STORAGE_KEY);
Vector extidIDs = cases.getIDsForValue("external-id", hhid);
Vector typeIDs = cases.getIDsForValue("case-type", "cc_case_house_visit");
boolean found = false;
//for each case with same ext id
for (int i = 0; i < extidIDs.size(); i++) {
int caseID = ((Integer)extidIDs.elementAt(i)).intValue();
//if one of the cases is of the house_visit type, AND it's open, we have a dup
if (typeIDs.contains(new Integer(caseID))) {
Case c = (Case)cases.read(caseID);
if (!c.isClosed()) {
found = true;
break;
}
}
}
return found;
}
示例12: getCase
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
private Case getCase(String id) {
IStorageUtilityIndexed storage = (IStorageUtilityIndexed)StorageManager.getStorage(Case.STORAGE_KEY);
try {
Case c = (Case)storage.getRecordForValue("case-id", id);
return c;
} catch (NoSuchElementException e) {
//We eventually probably want to deal with this. For now, it's a dealbreaker. Throw it up.
e.printStackTrace();
throw e;
} catch (InvalidIndexException iie) {
//We eventually probably want to deal with this. For now, it's a dealbreaker. Throw it up.
iie.printStackTrace();
throw iie;
}
}
示例13: populateAdminUser
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public static void populateAdminUser(MIDlet m) {
IStorageUtility users = StorageManager.getStorage(User.STORAGE_KEY);
boolean adminFound = false;
IStorageIterator ui = users.iterate();
while (ui.hasMore()) {
User user = (User)ui.nextRecord();
if (User.ADMINUSER.equals(user.getUserType())) {
adminFound = true;
break;
}
}
// There is no admin user to update, so add the user
if(!adminFound) {
//TODO: Test for MIDlet-Jar-RSA-SHA1 or other signing mechanism before allowing the property to be pulled?
String defaultFromEnvironment = m == null ? null : m.getAppProperty(ADMIN_PW_PROPERTY);
User admin = new User("admin", defaultFromEnvironment != null ? defaultFromEnvironment : defaultPassword, PropertyUtils.genGUID(25), User.ADMINUSER);
admin.setUuid(PropertyManager._().getSingularProperty("DeviceID"));
users.write(admin);
}
}
示例14: registerModule
import org.javarosa.core.services.storage.StorageManager; //导入依赖的package包/类
public void registerModule() {
//Note: Do not remove fully qualified names here, otherwise the imports mess up the polish preprocessing
//#if polish.api.wmapi
String[] prototypes = new String[] { SimpleHttpTransportMessage.class.getName(), org.javarosa.services.transport.impl.sms.SMSTransportMessage.class.getName(), org.javarosa.services.transport.impl.binarysms.BinarySMSTransportMessage.class.getName(), TransportMessageSerializationWrapper.class.getName(), org.javarosa.core.services.transport.payload.ByteArrayPayload.class.getName(), org.javarosa.core.services.transport.payload.DataPointerPayload.class.getName(), org.javarosa.core.services.transport.payload.MultiMessagePayload.class.getName(), org.javarosa.services.transport.impl.simplehttp.multipart.HttpTransportHeader.class.getName()};
//#else
//# String[] prototypes = new String[] { SimpleHttpTransportMessage.class.getName(), TransportMessageSerializationWrapper.class.getName(), org.javarosa.core.services.transport.payload.ByteArrayPayload.class.getName(), org.javarosa.core.services.transport.payload.DataPointerPayload.class.getName(), org.javarosa.core.services.transport.payload.MultiMessagePayload.class.getName(), org.javarosa.services.transport.impl.simplehttp.multipart.HttpTransportHeader.class.getName()};
//#endif
PrototypeManager.registerPrototypes(prototypes);
StorageManager.registerWrappedStorage(TransportMessageStore.Q_STORENAME, TransportMessageStore.Q_STORENAME, new TransportMessageSerializationWrapper());
StorageManager.registerWrappedStorage(TransportMessageStore.RECENTLY_SENT_STORENAME, TransportMessageStore.RECENTLY_SENT_STORENAME, new TransportMessageSerializationWrapper());
ReferenceManager._().addReferenceFactory(new HttpRoot(listener));
PropertyManager._().addRules(new TransportPropertyRules());
TransportService.init();
}
示例15: writeUserReport
import org.javarosa.core.services.storage.StorageManager; //导入依赖的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");
}
}