Search in sources :

Example 1 with CampaignLoader

use of pcgen.persistence.lst.CampaignLoader in project pcgen by PCGen.

the class CampaignFileLoader method initCampaigns.

/**
     * Goes through the campaigns in {@link #campaignFiles campaignFiles} and loads
     * data associated with dependent campaigns.
     */
private static void initCampaigns() {
    // This may modify the globals list; need a local copy so
    // the iteration doesn't fail.
    Iterable<Campaign> initialCampaigns = new ArrayList<>(Globals.getCampaignList());
    CampaignLoader campaignLoader = new CampaignLoader();
    for (final Campaign c : initialCampaigns) {
        campaignLoader.initRecursivePccFiles(c);
    }
}
Also used : Campaign(pcgen.core.Campaign) ArrayList(java.util.ArrayList) CampaignLoader(pcgen.persistence.lst.CampaignLoader)

Example 2 with CampaignLoader

use of pcgen.persistence.lst.CampaignLoader in project pcgen by PCGen.

the class CampaignFileLoader method loadCampaigns.

/**
     * Passes the campaign PCC files referenced by {@link #campaignFiles campaignFiles} to a {@link pcgen.persistence.lst.CampaignLoader CampaignLoader},
     * which will load the data within into the {@link pcgen.rules.context.LoadContext LoadContext} of the {@link pcgen.core.Campaign Campaign}.
     */
private void loadCampaigns() {
    int progress = 0;
    CampaignLoader campaignLoader = new CampaignLoader();
    while (!campaignFiles.isEmpty()) {
        // Pull the first URI from the list
        URI uri = campaignFiles.poll();
        // Do not load campaign if already loaded
        if (Globals.getCampaignByURI(uri, false) == null) {
            try {
                // Pass this URI to campaign loader
                campaignLoader.loadCampaignLstFile(uri);
            } catch (PersistenceLayerException ex) {
                // LATER: This is not an appropriate way to deal with this exception.
                // Deal with it this way because of the way the loading takes place.  XXX
                Logging.errorPrint("PersistanceLayer", ex);
            }
        }
        progress++;
        setProgress(progress);
    }
}
Also used : CampaignLoader(pcgen.persistence.lst.CampaignLoader) URI(java.net.URI)

Aggregations

CampaignLoader (pcgen.persistence.lst.CampaignLoader)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Campaign (pcgen.core.Campaign)1