当前位置: 首页>>代码示例>>Java>>正文


Java ResourceTable.getResourceWithId方法代码示例

本文整理汇总了Java中org.commcare.resources.model.ResourceTable.getResourceWithId方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceTable.getResourceWithId方法的具体用法?Java ResourceTable.getResourceWithId怎么用?Java ResourceTable.getResourceWithId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.commcare.resources.model.ResourceTable的用法示例。


在下文中一共展示了ResourceTable.getResourceWithId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:20,代码来源:ResourceManager.java

示例2: 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;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:20,代码来源:ResourceManager.java

示例3: installAppResources

import org.commcare.resources.model.ResourceTable; //导入方法依赖的package包/类
/**
 * Installs resources described by profile reference into the provided
 * resource table. If the resource table is ready or already has a profile,
 * don't do anything.
 *
 * @param profileReference URL to profile file
 * @param global           Add profile ref to this table and install its
 *                         resources
 * @param forceInstall     Should installation be performed regardless of
 *                         version numbers?
 */
public static void installAppResources(CommCarePlatform platform, String profileReference,
                                       ResourceTable global, boolean forceInstall)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {
    synchronized (updateLock) {
        try {
            if (!global.isReady()) {
                global.prepareResources(null, platform);
            }

            // First, see if the appropriate profile exists
            Resource profile =
                    global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);

            if (profile == null) {
                // grab the local profile and parse it
                Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
                locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_LOCAL, profileReference));

                // We need a way to identify this version...
                Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
                        CommCarePlatform.APP_PROFILE_RESOURCE_ID,
                        locations, "Application Descriptor");

                global.addResource(r, global.getInstallers().getProfileInstaller(forceInstall), "");
                global.prepareResources(null, platform);
            }
        } catch (StorageFullException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:45,代码来源:ResourceManager.java

示例4: upgradeTableVersion

import org.commcare.resources.model.ResourceTable; //导入方法依赖的package包/类
/**
 * @return Version from profile in the app's upgrade table; -1 if upgrade
 * profile not found.
 */
public static int upgradeTableVersion() {
    CommCareApp app = CommCareApplication.instance().getCurrentApp();
    AndroidCommCarePlatform platform = app.getCommCarePlatform();

    ResourceTable upgradeTable = platform.getUpgradeResourceTable();

    Resource upgradeProfile =
            upgradeTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
    if (upgradeProfile == null) {
        return -1;
    }
    return upgradeProfile.getVersion();
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:18,代码来源:ResourceInstallUtils.java

示例5: installAppResources

import org.commcare.resources.model.ResourceTable; //导入方法依赖的package包/类
/**
 * Installs resources described by profile reference into the provided
 * resource table. If the resource table is ready or already has a profile,
 * don't do anything.
 *
 * @param profileReference URL to profile file
 * @param global           Add profile ref to this table and install its
 *                         resources
 * @param forceInstall     Should installation be performed regardless of
 *                         version numbers?
 */
public static void installAppResources(CommCarePlatform platform, String profileReference,
                                       ResourceTable global, boolean forceInstall,
                                       int authorityForProfile)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {
    synchronized (platform) {
        if (!global.isReady()) {
            global.prepareResources(null, platform);
        }

        // First, see if the appropriate profile exists
        Resource profile =
                global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);

        if (profile == null) {
            // Create a stub for the profile resource that points to the authority and location
            // from which we will install it
            Vector<ResourceLocation> locations = new Vector<>();
            locations.addElement(new ResourceLocation(authorityForProfile, profileReference));
            Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
                    CommCarePlatform.APP_PROFILE_RESOURCE_ID,
                    locations, "Application Descriptor");

            global.addResource(r, global.getInstallers().getProfileInstaller(forceInstall), "");
            global.prepareResources(null, platform);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:41,代码来源:ResourceManager.java

示例6: initializeApplicationHelper

import org.commcare.resources.model.ResourceTable; //导入方法依赖的package包/类
private boolean initializeApplicationHelper() {
    setupSandbox();

    ResourceTable global = platform.getGlobalResourceTable();
    ResourceTable upgrade = platform.getUpgradeResourceTable();
    ResourceTable recovery = platform.getRecoveryTable();

    logTable("Global", global);
    logTable("Upgrade", upgrade);
    logTable("Recovery", recovery);

    // See if any of our tables got left in a weird state
    if (global.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
        global.rollbackCommits(platform);
        logTable("Global after rollback", global);
    }
    if (upgrade.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
        upgrade.rollbackCommits(platform);
        logTable("Upgrade after rollback", upgrade);
    }

    // See if we got left in the middle of an update
    if (global.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNSTAGED) {
        // If so, repair the global table. (Always takes priority over maintaining the update)
        global.repairTable(upgrade, platform);
    }

    Resource profile = global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
    if (profile != null && profile.getStatus() == Resource.RESOURCE_STATUS_INSTALLED) {
        platform.initialize(global, false);
        try {
            Localization.setLocale(
                    getAppPreferences().getString(MainConfigurablePreferences.PREFS_LOCALE_KEY, "default"));
        } catch (UnregisteredLocaleException urle) {
            Localization.setLocale(Localization.getGlobalLocalizerAdvanced().getAvailableLocales()[0]);
        }

        initializeStylizer();

        try {
            HybridFileBackedSqlHelpers.removeOrphanedFiles(buildAndroidDbHelper().getHandle());
        } catch (SessionUnavailableException e) {
            Logger.log(LogTypes.SOFT_ASSERT,
                    "Unable to get app db handle to clear orphaned files");
        }
        return true;
    }

    String failureReason = profile == null ? "profle being null" : "profile status value " + String.valueOf(profile.getStatus());
    Logger.log(LogTypes.TYPE_RESOURCES, "Initializing application failed because of " + failureReason);
    return false;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:53,代码来源:CommCareApp.java


注:本文中的org.commcare.resources.model.ResourceTable.getResourceWithId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。