@Test public void testInputTemplateTest() throws IOException { Provider<Locale> localeProvider = EasyMock.createMock(_TestLocaleProvider.class); EasyMock.expect(localeProvider.get()).andReturn(Locale.getDefault()).anyTimes(); ResourceBundleService resb = EasyMock.createMock(ResourceBundleService.class); PropertyResourceBundle resourceBundle = new PropertyResourceBundle(new StringReader(BUNDLES)); EasyMock.expect(resb.getResourceBundle("labels", Locale.getDefault())).andReturn(resourceBundle).anyTimes(); KConfiguration conf = EasyMock.createMock(KConfiguration.class); EasyMock.expect(conf.getProperty("migration.target.directory")).andReturn(System.getProperty("user.dir")).anyTimes(); EasyMock.expect(conf.getProperty("migration.directory")).andReturn(System.getProperty("user.dir")).anyTimes(); Configuration subConfObject = EasyMock.createMock(Configuration.class); EasyMock.expect(conf.getConfiguration()).andReturn(subConfObject).anyTimes(); EasyMock.expect(subConfObject.getBoolean("ingest.skip")).andReturn(true).anyTimes(); EasyMock.expect(subConfObject.getBoolean("ingest.startIndexer")).andReturn(true).anyTimes(); EasyMock.expect(subConfObject.getBoolean("convert.defaultRights")).andReturn(true).anyTimes(); EasyMock.replay(localeProvider,resb, conf, subConfObject); InputTemplate temp = new InputTemplate(); temp.configuration=conf; temp.localesProvider = localeProvider; temp.resourceBundleService = resb; StringWriter nstr = new StringWriter(); temp.renderInput(null,nstr, new Properties()); Assert.assertNotNull(nstr.toString()); }
@Override public void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping) throws IOException { File homeFolder = new File(configuration.getProperty("migration.directory")); InputStream iStream = this.getClass().getResourceAsStream("replicationtemplate.st"); TreeItem rootNode = TreeModelUtils.prepareTreeModel(homeFolder,new TreeModelFilter() { String[] NAMES = { "lp","exported","deepZoom" }; @Override public boolean accept(File file) { String sname = file.getName(); for (String nm : NAMES) { if (nm.equals(sname)) return false; } return true; } }); StringTemplateGroup templateGroup = new StringTemplateGroup(new InputStreamReader(iStream,"UTF-8"), DefaultTemplateLexer.class); templateGroup.setSuperGroup(BasicStringTemplateGroup.getBasicProcessesGroup()); StringTemplate template = templateGroup.getInstanceOf("form"); template.setAttribute("migrationDirectory", configuration.getProperty("migration.directory")); template.setAttribute("targetDirectory", configuration.getProperty("migration.target.directory")); template.setAttribute("importRootDirectory", rootNode); Boolean visibility = configuration.getConfiguration().getBoolean("convert.defaultRights"); template.setAttribute("visibility", visibility); LOGGER.info("visibility :"+visibility); Boolean importToFedora = !configuration.getConfiguration().getBoolean("ingest.skip"); Boolean startIndexer = configuration.getConfiguration().getBoolean("ingest.startIndexer"); OtherSettingsTemplate oSettings = OtherSettingsTemplate.disectTemplate(importToFedora, startIndexer); template.setAttribute("otherSettingsTemplate", oSettings.name()); ResourceBundle resbundle = resourceBundleService.getResourceBundle("labels", localesProvider.get()); template.setAttribute("bundle", ResourceBundleUtils.resourceBundleMap(resbundle)); writer.write(template.toString()); }
InputTemplate implements ProcessInputTemplate { @Override public void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping) throws IOException { File homeFolder = new File(configuration.getProperty("migration.directory")); InputStream iStream = this.getClass().getResourceAsStream("replicationtemplate.st"); TreeItem rootNode = TreeModelUtils.prepareTreeModel(homeFolder,new TreeModelFilter() { String[] NAMES = { "lp","exported","deepZoom" }; @Override public boolean accept(File file) { String sname = file.getName(); for (String nm : NAMES) { if (nm.equals(sname)) return false; } return true; } }); StringTemplateGroup templateGroup = new StringTemplateGroup(new InputStreamReader(iStream,"UTF-8"), DefaultTemplateLexer.class); templateGroup.setSuperGroup(BasicStringTemplateGroup.getBasicProcessesGroup()); StringTemplate template = templateGroup.getInstanceOf("form"); template.setAttribute("migrationDirectory", configuration.getProperty("migration.directory")); template.setAttribute("targetDirectory", configuration.getProperty("migration.target.directory")); template.setAttribute("importRootDirectory", rootNode); Boolean visibility = configuration.getConfiguration().getBoolean("convert.defaultRights"); template.setAttribute("visibility", visibility); LOGGER.info("visibility :"+visibility); Boolean importToFedora = !configuration.getConfiguration().getBoolean("ingest.skip"); Boolean startIndexer = configuration.getConfiguration().getBoolean("ingest.startIndexer"); OtherSettingsTemplate oSettings = OtherSettingsTemplate.disectTemplate(importToFedora, startIndexer); template.setAttribute("otherSettingsTemplate", oSettings.name()); ResourceBundle resbundle = resourceBundleService.getResourceBundle("labels", localesProvider.get()); template.setAttribute("bundle", ResourceBundleUtils.resourceBundleMap(resbundle)); writer.write(template.toString()); } }
InputTemplate implements ProcessInputTemplate { @Override public void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping) throws IOException { File homeFolder = new File(configuration.getProperty("migration.directory")); InputStream iStream = this.getClass().getResourceAsStream("replicationtemplate.st"); TreeItem rootNode = TreeModelUtils.prepareTreeModel(homeFolder,new TreeModelFilter() { String[] NAMES = { "lp","exported","deepZoom" }; @Override public boolean accept(File file) { String sname = file.getName(); for (String nm : NAMES) { if (nm.equals(sname)) return false; } return true; } }); StringTemplateGroup templateGroup = new StringTemplateGroup(new InputStreamReader(iStream,"UTF-8"), DefaultTemplateLexer.class); templateGroup.setSuperGroup(BasicStringTemplateGroup.getBasicProcessesGroup()); StringTemplate template = templateGroup.getInstanceOf("form"); template.setAttribute("migrationDirectory", configuration.getProperty("migration.directory")); template.setAttribute("targetDirectory", configuration.getProperty("migration.target.directory")); template.setAttribute("importRootDirectory", rootNode); Boolean visibility = configuration.getConfiguration().getBoolean("convert.defaultRights"); template.setAttribute("visibility", visibility); LOGGER.info("visibility :"+visibility); Boolean importToFedora = !configuration.getConfiguration().getBoolean("ingest.skip"); Boolean startIndexer = configuration.getConfiguration().getBoolean("ingest.startIndexer"); OtherSettingsTemplate oSettings = OtherSettingsTemplate.disectTemplate(importToFedora, startIndexer); template.setAttribute("otherSettingsTemplate", oSettings.name()); ResourceBundle resbundle = resourceBundleService.getResourceBundle("labels", localesProvider.get()); template.setAttribute("bundle", ResourceBundleUtils.resourceBundleMap(resbundle)); writer.write(template.toString()); }  }
InputTemplate implements ProcessInputTemplate { @Override public void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping) throws IOException { File homeFolder = new File(configuration.getProperty("migration.directory")); InputStream iStream = this.getClass().getResourceAsStream("replicationtemplate.st"); TreeItem rootNode = TreeModelUtils.prepareTreeModel(homeFolder,new TreeModelFilter() { String[] NAMES = { "lp","exported","deepZoom" }; @Override public boolean accept(File file) { String sname = file.getName(); for (String nm : NAMES) { if (nm.equals(sname)) return false; } return true; } }); StringTemplateGroup templateGroup = new StringTemplateGroup(new InputStreamReader(iStream,"UTF-8"), DefaultTemplateLexer.class); templateGroup.setSuperGroup(BasicStringTemplateGroup.getBasicProcessesGroup()); StringTemplate template = templateGroup.getInstanceOf("form"); template.setAttribute("migrationDirectory", configuration.getProperty("migration.directory")); template.setAttribute("targetDirectory", configuration.getProperty("migration.target.directory")); template.setAttribute("importRootDirectory", rootNode); Boolean visibility = configuration.getConfiguration().getBoolean("convert.defaultRights"); template.setAttribute("visibility", visibility); LOGGER.info("visibility :"+visibility); Boolean importToFedora = !configuration.getConfiguration().getBoolean("ingest.skip"); Boolean startIndexer = configuration.getConfiguration().getBoolean("ingest.startIndexer"); OtherSettingsTemplate oSettings = OtherSettingsTemplate.disectTemplate(importToFedora, startIndexer); template.setAttribute("otherSettingsTemplate", oSettings.name()); ResourceBundle resbundle = resourceBundleService.getResourceBundle("labels", localesProvider.get()); template.setAttribute("bundle", ResourceBundleUtils.resourceBundleMap(resbundle)); writer.write(template.toString()); }  @Override void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping); }
InputTemplate implements ProcessInputTemplate { @Override public void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping) throws IOException { File homeFolder = new File(configuration.getProperty("migration.directory")); InputStream iStream = this.getClass().getResourceAsStream("replicationtemplate.st"); TreeItem rootNode = TreeModelUtils.prepareTreeModel(homeFolder,new TreeModelFilter() { String[] NAMES = { "lp","exported","deepZoom" }; @Override public boolean accept(File file) { String sname = file.getName(); for (String nm : NAMES) { if (nm.equals(sname)) return false; } return true; } }); StringTemplateGroup templateGroup = new StringTemplateGroup(new InputStreamReader(iStream,"UTF-8"), DefaultTemplateLexer.class); templateGroup.setSuperGroup(BasicStringTemplateGroup.getBasicProcessesGroup()); StringTemplate template = templateGroup.getInstanceOf("form"); template.setAttribute("migrationDirectory", configuration.getProperty("migration.directory")); template.setAttribute("targetDirectory", configuration.getProperty("migration.target.directory")); template.setAttribute("importRootDirectory", rootNode); Boolean visibility = configuration.getConfiguration().getBoolean("convert.defaultRights"); template.setAttribute("visibility", visibility); LOGGER.info("visibility :"+visibility); Boolean importToFedora = !configuration.getConfiguration().getBoolean("ingest.skip"); Boolean startIndexer = configuration.getConfiguration().getBoolean("ingest.startIndexer"); OtherSettingsTemplate oSettings = OtherSettingsTemplate.disectTemplate(importToFedora, startIndexer); template.setAttribute("otherSettingsTemplate", oSettings.name()); ResourceBundle resbundle = resourceBundleService.getResourceBundle("labels", localesProvider.get()); template.setAttribute("bundle", ResourceBundleUtils.resourceBundleMap(resbundle)); writer.write(template.toString()); }  @Override void renderInput(LRProcessDefinition definition, Writer writer, Properties paramsMapping);  }