pdb.repopulateCMT(completeSociety);
if (log.isDebugEnabled()) { log.debug("save: After modifying CDATA by comp " + soc.getShortName() + ", got a removed."); } pdb.populateCSA(completeSociety);
  public void saveToDb(DBConflictHandler ch) {    try {      updateNameServerHostName(); // Be sure this is up-to-date      List components = getComponents();      boolean componentWasRemoved = false;      PopulateDb pdb = null;      SocietyComponent sc = getSocietyComponent();      if (sc == null) {        if (log.isErrorEnabled())           log.error("Experiment has no society; cannot save it to database.");        return;      }      if (sc instanceof SocietyFileComponent ||          sc instanceof SocietyUIComponent) {	// Created with a SocietyFileComponent	// Have no CMT assembly, nor previous	// experiment or trial ID.	// FIXME: Save it in a CSA and CSMI!	// new PopulateDb("CSA", "CSHNA", "CSMI"....	// So save it all in the CSMI assembly        pdb =          new PopulateDb("CSHNA", "CSMI", getExperimentName(),                         null, null, ch);      } else {	// We'll clear out the old non-CMT assemblies,	// save everything in CMT / CSMI        pdb =          new PopulateDb("CMT", "CSHNA", "CSMI", getExperimentName(),                         getExperimentID(), trialID, ch);      }      setExperimentID(pdb.getExperimentId());      setTrialID(pdb.getTrialId()); // sets trial id and -D argument      // Some components will want access to the complete set of Nodes      // in the society, etc. To get that, they must get back to the      // root soc object, and do a getOwner and go from there. Ugly.      // So far we've just created the pdb (which      // sets up the Experimet & Trial IDs, and puts the CMT assembly      // in the right place if necc, and clears out the other       // assemblies (CSMI, CSHNA)      // Gather the HostNodeAgent stuff      generateHNACDATA();      if(log.isErrorEnabled() && completeSociety == null) {        log.error("Society Data is null!");      }      // Save what we have so far in the CSHNA assembly      pdb.populateHNA(completeSociety);      // Now let components add in their pieces      componentWasRemoved = askComponentsToAddCDATA();      // If any component removed something, we need      // to recreate the CMT assembly (under the original ID)      // So this, currently destroys the orig CMT      // Note also it does not effect Agent asset data      // or relationships or OPLAN stuff      if (componentWasRemoved) pdb.repopulateCMT(completeSociety);      // FIXME: Replace above with populateCSA or some such      // then give everyone a chance to modify what they've collectively produced      for (int i = 0, n = components.size(); i < n; i++) {        BaseComponent soc = (BaseComponent) components.get(i);        soc.modifyComponentData(completeSociety, pdb);        if (soc.componentWasRemoved()) {          pdb.repopulateCMT(completeSociety);        }        pdb.populateCSMI(completeSociety);      }      pdb.setModRecipes(recipes);      // Now make sure the runtime/ config time assemblies      // are all correct      if (! pdb.fixAssemblies()) {	// Some sort of error trying to ensure the assemblies are all correct.	if (log.isErrorEnabled()) {	  log.error("Failed to ensure correct assemblies saved.");	}      }      pdb.close();    } catch (Exception sqle) {      if (log.isErrorEnabled())	log.error("Error saving experiment to database: ", sqle);      return;    }    resetModified();  }