protected void processCPTemplates() throws SetupException { List<String> filenames = this.getFilenames(); ManagementBeanFactory factory = null; try { factory = this.getManagementBeanFactory(); ModelBean modelBean = factory.createModelBean(); ClientProvTemplateBean cpBean = factory.createClientProvTemplateBean(); // Import Profile Mappings for (String filename : filenames) { // Process the file, and import data into database. File file = new File(filename); if (!file.isAbsolute()) { file = new File(this.getSetup().getWorkDir(), filename); } this.getSetup() .getConsole() .println(" Loading file [ " + file.getAbsolutePath() + " ]"); List<ManufacturerItem> items = this.loadManufacturerItems(file.getAbsolutePath()); for (ManufacturerItem manufacturerItem : items) { List<ModelItem> modelItems = manufacturerItem.getModels(); Manufacturer manufacturer = modelBean.getManufacturerByExternalID(manufacturerItem.getExternalID()); for (ModelItem modelItem : modelItems) { // Copy information from family this.copyFromFamily(modelItem); Model model = modelBean.getModelByManufacturerModelID(manufacturer, modelItem.getExternalID()); if (!modelItem.getCpTemplatesFiles().isEmpty()) { this.getSetup() .getConsole() .println( " * Importing CP Templates for [ " + manufacturer.getExternalId() + " " + model.getManufacturerModelId() + " ]"); } for (String templateFilename : modelItem.getCpTemplatesFiles()) { File templateFile = new File(templateFilename); if (!templateFile.isAbsolute()) { templateFile = new File(this.getSetup().getWorkDir(), templateFilename); } InputStream in = new FileInputStream(templateFile); List<ClientProvTemplate> templates = cpBean.importClientProvTemplates(in, this.getSetup().getWorkDir()); factory.beginTransaction(); for (ClientProvTemplate template : templates) { cpBean.attach(model, template); } factory.commit(); this.getSetup().getConsole().println(" [ " + templateFile + " ] imported!"); } } } } } catch (Exception ex) { if (factory != null) { factory.rollback(); } throw new SetupException("Error in import models.", ex); } finally { if (factory != null) { factory.release(); } } }