當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceTable類代碼示例

本文整理匯總了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;
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:19,代碼來源:CommCareContext.java

示例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");
        }
    }
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:19,代碼來源:ResourceTableSubreport.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:18,代碼來源:XFormInstaller.java

示例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);
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:20,代碼來源:ResourceManager.java

示例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);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:28,代碼來源:ResourceManager.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:20,代碼來源:ResourceManager.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:19,代碼來源:VerificationTask.java

示例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);
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:20,代碼來源:UpdateTask.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:19,代碼來源:XFormInstaller.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:20,代碼來源:OfflineUserRestoreInstaller.java

示例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);
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:20,代碼來源:ResourceManager.java

示例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);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:29,代碼來源:ResourceManager.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:20,代碼來源:ResourceManager.java

示例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)));
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:23,代碼來源:CommCareConfigEngine.java

示例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;
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:12,代碼來源:CommCareContext.java


注:本文中的org.commcare.resources.model.ResourceTable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。