本文整理汇总了Java中org.commcare.resources.model.ResourceTable类的典型用法代码示例。如果您正苦于以下问题:Java ResourceTable类的具体用法?Java ResourceTable怎么用?Java ResourceTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceTable类属于org.commcare.resources.model包,在下文中一共展示了ResourceTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CreateTemporaryResourceTable
import org.commcare.resources.model.ResourceTable; //导入依赖的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;
}
示例2: writeToDeviceReport
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
public void writeToDeviceReport(XmlSerializer o) throws IOException {
o.startTag(DeviceReportState.XMLNS, "globaltable_subreport");
try {
for(Resource r : ResourceManager.getResourceListFromProfile(table)) {
o.startTag(DeviceReportState.XMLNS, "resource");
try {
o.attribute(null, "id", r.getResourceId());
o.attribute(null, "version", String.valueOf(r.getVersion()));
DeviceReportState.writeText(o, "status", ResourceTable.getStatusString(r.getStatus()));
}finally {
o.endTag(DeviceReportState.XMLNS, "resource");
}
}
} finally {
o.endTag(DeviceReportState.XMLNS, "globaltable_subreport");
}
}
示例3: revert
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
public boolean revert(Resource r, ResourceTable table) {
//Basically some content as upgrade. Merge;
FormDef form = storage().read(cacheLocation);
String tempString = form.getInstance().schema;
//TODO: Aggressively wipe out anything which might conflict with the uniqueness
//of the new schema
for (String ext : exts) {
//Removing any staging/upgrade placeholders.
if (tempString.indexOf(ext) != -1) {
form.getInstance().schema = tempString.substring(0, tempString.indexOf(ext));
storage().write(form);
}
}
return true;
}
示例4: loadProfileIntoTable
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
protected void loadProfileIntoTable(ResourceTable table,
String profileRef,
int authority)
throws UnfullfilledRequirementsException,
UnresolvedResourceException,
InstallCancelledException {
Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
locations.addElement(new ResourceLocation(authority, profileRef));
Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
CommCarePlatform.APP_PROFILE_RESOURCE_ID, locations,
"Application Descriptor");
table.addResource(r,
table.getInstallers().getProfileInstaller(false),
null);
prepareProfileResource(table);
}
示例5: prepareUpgradeResources
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
/**
* Download resources referenced by upgrade table's profile into the
* upgrade table itself.
*
* @throws InstallCancelledException The user/system has cancelled the
* installation process
*/
public void prepareUpgradeResources()
throws UnfullfilledRequirementsException,
UnresolvedResourceException, IllegalArgumentException,
InstallCancelledException {
synchronized (updateLock) {
ensureMasterTableValid();
// TODO: Table's acceptable states here may be incomplete
int upgradeTableState = upgradeTable.getTableReadiness();
if (upgradeTableState == ResourceTable.RESOURCE_TABLE_UNCOMMITED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_UNSTAGED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_EMPTY) {
throw new IllegalArgumentException("Upgrade table is not in an appropriate state");
}
tempTable.destroy();
upgradeTable.prepareResources(masterTable, this.platform);
}
}
示例6: getResourceListFromProfile
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
public static Vector<Resource> getResourceListFromProfile(ResourceTable master) {
Vector<Resource> unresolved = new Vector<Resource>();
Vector<Resource> resolved = new Vector<Resource>();
Resource r = master.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (r == null) {
return resolved;
}
unresolved.addElement(r);
while (unresolved.size() > 0) {
Resource current = unresolved.firstElement();
unresolved.removeElement(current);
resolved.addElement(current);
Vector<Resource> children = master.getResourcesForParent(current.getRecordGuid());
for (Resource child : children) {
unresolved.addElement(child);
}
}
return resolved;
}
示例7: doTaskBackground
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
@Override
protected SizeBoundVector<MissingMediaException> doTaskBackground(Void... params) {
AndroidCommCarePlatform platform = CommCareApplication.instance().getCommCarePlatform();
// This is replicated in the application in a few places.
ResourceTable global = platform.getGlobalResourceTable();
SizeBoundUniqueVector<MissingMediaException> problems =
new SizeBoundUniqueVector<>(10);
setTableListeners(global);
global.verifyInstallation(problems, platform);
unsetTableListeners(global);
if (problems.size() > 0) {
return problems;
}
return null;
}
示例8: compoundResourceAdded
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
/**
* Calculate and report the resource install progress a table has made.
*/
@Override
public void compoundResourceAdded(ResourceTable table) {
Vector<Resource> resources =
AndroidResourceManager.getResourceListFromProfile(table);
currentProgress = 0;
for (Resource r : resources) {
int resourceStatus = r.getStatus();
if (resourceStatus == Resource.RESOURCE_STATUS_UPGRADE ||
resourceStatus == Resource.RESOURCE_STATUS_INSTALLED) {
currentProgress += 1;
}
}
maxProgress = resources.size();
incrementProgress(currentProgress, maxProgress);
}
示例9: revert
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
@Override
public boolean revert(Resource r, ResourceTable table, CommCarePlatform platform) {
//Basically some content as upgrade. Merge;
FormDef form = storage(platform).read(cacheLocation);
String tempString = form.getInstance().schema;
//TODO: Aggressively wipe out anything which might conflict with the uniqueness
//of the new schema
for (String ext : exts) {
//Removing any staging/upgrade placeholders.
if (tempString.contains(ext)) {
form.getInstance().schema = tempString.substring(0, tempString.indexOf(ext));
storage(platform).write(form);
}
}
return true;
}
示例10: install
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
@Override
public boolean install(Resource r, ResourceLocation location,
Reference ref, ResourceTable table,
CommCarePlatform platform, boolean upgrade)
throws UnresolvedResourceException, UnfullfilledRequirementsException {
try {
OfflineUserRestore offlineUserRestore = OfflineUserRestore.buildInMemoryUserRestore(ref.getStream());
storage(platform).write(offlineUserRestore);
if (upgrade) {
table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
} else {
table.commit(r, Resource.RESOURCE_STATUS_UPGRADE);
}
cacheLocation = offlineUserRestore.getID();
} catch (IOException | XmlPullParserException | InvalidStructureException e) {
throw new UnresolvedResourceException(r, e.getMessage());
}
return true;
}
示例11: loadProfileIntoTable
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
protected void loadProfileIntoTable(ResourceTable table,
String profileRef,
int authority)
throws UnfullfilledRequirementsException,
UnresolvedResourceException,
InstallCancelledException {
Vector<ResourceLocation> locations = new Vector<>();
locations.addElement(new ResourceLocation(authority, profileRef));
Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
CommCarePlatform.APP_PROFILE_RESOURCE_ID, locations,
"Application Descriptor");
table.addResource(r,
table.getInstallers().getProfileInstaller(false),
null);
prepareProfileResource(table);
}
示例12: prepareUpgradeResources
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
/**
* Download resources referenced by upgrade table's profile into the
* upgrade table itself.
*
* @throws InstallCancelledException The user/system has cancelled the
* installation process
*/
public void prepareUpgradeResources()
throws UnfullfilledRequirementsException,
UnresolvedResourceException, IllegalArgumentException,
InstallCancelledException {
synchronized (platform) {
ensureMasterTableValid();
// TODO: Table's acceptable states here may be incomplete
int upgradeTableState = upgradeTable.getTableReadiness();
if (upgradeTableState == ResourceTable.RESOURCE_TABLE_UNCOMMITED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_UNSTAGED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_EMPTY) {
throw new IllegalArgumentException("Upgrade table is not in an appropriate state");
}
tempTable.destroy();
upgradeTable.setResourceProgressStale();
upgradeTable.prepareResources(masterTable, this.platform);
}
}
示例13: getResourceListFromProfile
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
public static Vector<Resource> getResourceListFromProfile(ResourceTable master) {
Vector<Resource> unresolved = new Vector<>();
Vector<Resource> resolved = new Vector<>();
Resource r = master.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (r == null) {
return resolved;
}
unresolved.addElement(r);
while (unresolved.size() > 0) {
Resource current = unresolved.firstElement();
unresolved.removeElement(current);
resolved.addElement(current);
Vector<Resource> children = master.getResourcesForParent(current.getRecordGuid());
for (Resource child : children) {
unresolved.addElement(child);
}
}
return resolved;
}
示例14: CommCareConfigEngine
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
public CommCareConfigEngine(IStorageIndexedFactory storageFactory,
InstallerFactory installerFactory) {
this.print = new PrintStream(System.out);
setRoots();
table = ResourceTable.RetrieveTable(storageFactory.newStorage("GLOBAL_RESOURCE_TABLE", Resource.class), installerFactory);
updateTable = ResourceTable.RetrieveTable(storageFactory.newStorage("GLOBAL_UPGRADE_TABLE", Resource.class), installerFactory);
recoveryTable = ResourceTable.RetrieveTable(storageFactory.newStorage("GLOBAL_RECOVERY_TABLE", Resource.class), installerFactory);
StorageManager storageManager = new StorageManager(storageFactory);
storageManager.registerStorage(PropertyManager.STORAGE_KEY, Property.class);
storageManager.registerStorage(Profile.STORAGE_KEY, Profile.class);
storageManager.registerStorage(Suite.STORAGE_KEY, Suite.class);
storageManager.registerStorage(FormDef.STORAGE_KEY, FormDef.class);
storageManager.registerStorage(FormInstance.STORAGE_KEY, FormInstance.class);
storageManager.registerStorage(OfflineUserRestore.STORAGE_KEY, OfflineUserRestore.class);
this.platform = new CommCarePlatform(MAJOR_VERSION, MINOR_VERSION,
storageManager,
new PropertyManager(storageManager.getStorage(PropertyManager.STORAGE_KEY)));
}
示例15: RetrieveGlobalResourceTable
import org.commcare.resources.model.ResourceTable; //导入依赖的package包/类
/**
* @return A static resource table which
*/
public static ResourceTable RetrieveGlobalResourceTable() {
if(global == null) {
global = ResourceTable.RetrieveTable((IStorageUtilityIndexed)StorageManager.getStorage(STORAGE_TABLE_GLOBAL));
}
//Not sure if this reference is actually a good idea, or whether we should
//get the storage link every time... For now, we'll reload storage each time
return global;
}