public Nodes withNodeLabel(Collection<NodeLabel> values) { if (values!= null) { getNodeLabel().addAll(values); } return this; }
/** * Create an instance of {@link Nodes } * */ public Nodes createNodes() { return new Nodes(); }
public Nodes withMigrationXsl(String value) { setMigrationXsl(value); return this; }
String searchPathForLabels = nodes.getSearchPath(); LOGGER.info("Found searchPathForLabels: {}", searchPathForLabels); for (org.bidib.wizard.migration.schema.nodes.NodeLabel nodeLabel : nodes.getNodeLabel()) { LOGGER.info("Collect labels for node: {}", nodeLabel); + NodeUtils.formatHexUniqueId(nodeLabel.getUniqueId()) + "' to file: " + file.getPath() + EOL); if (Bidib2LabelMigrator.class.getName().equals(nodes.getMigratorClass())) { Bidib2LabelMigrator.moveSourceFileToBackupDir(nodes.getSearchPath(), nodeLabel.getUniqueId()); if (StringUtils.isNotBlank(result)) { migrationFileWriter.write(result + EOL);
@Override public Nodes findAllNodesInWizardLabels(String searchpath) { // search all .xml files Iterator<File> labelFiles = FileUtils.iterateFiles(new File(searchpath), new String[] { "xml" }, false); Nodes nodes = null; while (labelFiles.hasNext()) { File labelFile = labelFiles.next(); LOGGER.info("Found labelFile: {}", labelFile); String fileName = FilenameUtils.getBaseName(labelFile.getName()); long uniqueId = NodeUtils.parseUniqueId(fileName); if (nodes == null) { // create default empty Nodes instance nodes = new Nodes().withSearchPath(searchpath); } NodeLabel nodeLabel = new NodeLabel(); nodeLabel.withUniqueId(uniqueId); nodes.withNodeLabel(nodeLabel); } if (nodes != null) { LOGGER.info("Set the migrator class."); nodes.setMigratorClass(getClass().getName()); } return nodes; }
String migrationXsl = nodes.getMigrationXsl(); if (StringUtils.isBlank(migrationXsl)) { migrationXsl = INPUT3_XSL; if (macroNodes != null && CollectionUtils.isNotEmpty(macroNodes.getNodeLabel())) { appendNodeLabels(nodes.getNodeLabel(), macroNodes.getNodeLabel()); if (accessoryNodes != null && CollectionUtils.isNotEmpty(accessoryNodes.getNodeLabel())) { appendNodeLabels(nodes.getNodeLabel(), accessoryNodes.getNodeLabel()); if (feedbackPortNodes != null && CollectionUtils.isNotEmpty(feedbackPortNodes.getNodeLabel())) { appendNodeLabels(nodes.getNodeLabel(), feedbackPortNodes.getNodeLabel()); if (switchPortNodes != null && CollectionUtils.isNotEmpty(switchPortNodes.getNodeLabel())) { appendNodeLabels(nodes.getNodeLabel(), switchPortNodes.getNodeLabel()); if (servoPortNodes != null && CollectionUtils.isNotEmpty(servoPortNodes.getNodeLabel())) { appendNodeLabels(nodes.getNodeLabel(), servoPortNodes.getNodeLabel()); if (backlightPortNodes != null && CollectionUtils.isNotEmpty(backlightPortNodes.getNodeLabel())) { appendNodeLabels(nodes.getNodeLabel(), backlightPortNodes.getNodeLabel()); if (lightPortNodes != null && CollectionUtils.isNotEmpty(lightPortNodes.getNodeLabel())) {
if (macroNodes != null && CollectionUtils.isNotEmpty(macroNodes.getNodeLabel())) { if (nodes == null) { nodes = new Nodes(); appendNodeLabels(nodes.getNodeLabel(), macroNodes.getNodeLabel()); if (accessoryNodes != null && CollectionUtils.isNotEmpty(accessoryNodes.getNodeLabel())) { if (nodes == null) { nodes = new Nodes(); appendNodeLabels(nodes.getNodeLabel(), accessoryNodes.getNodeLabel()); if (feedbackPortNodes != null && CollectionUtils.isNotEmpty(feedbackPortNodes.getNodeLabel())) { if (nodes == null) { nodes = new Nodes(); appendNodeLabels(nodes.getNodeLabel(), feedbackPortNodes.getNodeLabel()); if (switchPortNodes != null && CollectionUtils.isNotEmpty(switchPortNodes.getNodeLabel())) { if (nodes == null) { nodes = new Nodes(); appendNodeLabels(nodes.getNodeLabel(), switchPortNodes.getNodeLabel()); if (servoPortNodes != null && CollectionUtils.isNotEmpty(servoPortNodes.getNodeLabel())) { if (nodes == null) { nodes = new Nodes(); appendNodeLabels(nodes.getNodeLabel(), servoPortNodes.getNodeLabel());
Assert.assertNotNull(nodes.getSearchPath()); Assert.assertNotNull(nodes.getNodeLabel()); Assert.assertEquals(nodes.getNodeLabel().size(), 6); String searchPathForLabels = nodes.getSearchPath(); for (org.bidib.wizard.migration.schema.nodes.NodeLabel nodeLabel : nodes.getNodeLabel()) { LOGGER.info("Collect labels for node: {}", nodeLabel);
nodes = bidib2LabelMigrator.findAllNodesInWizardLabels(searchpath); if (nodes != null && CollectionUtils.isNotEmpty(nodes.getNodeLabel())) { LOGGER.info("Migration of labels from Bidib2 format passed."); migratorClassHolder[0] = Bidib2LabelMigrator.class; nodes = wizardLabelMigrator.findAllNodesInWizardLabels(searchpath); if (nodes != null && CollectionUtils.isNotEmpty(nodes.getNodeLabel())) { LOGGER.info("Migration of labels from Wizard format passed."); migratorClassHolder[0] = WizardLabelMigrator.class; nodes = oldWizardLabelMigrator.findAllNodesInWizardLabels(searchpath); if (nodes != null && CollectionUtils.isNotEmpty(nodes.getNodeLabel())) { LOGGER.info("Migration of node labels from old Wizard format passed."); migratorClassHolder[0] = OldWizardLabelMigrator.class; nodes.setSearchPath(searchpath); break;
public Nodes withSearchPath(String value) { setSearchPath(value); return this; }
public Nodes withMigratorClass(String value) { setMigratorClass(value); return this; }
Assert.assertNotNull(nodes.getSearchPath()); Assert.assertNotNull(nodes.getNodeLabel()); Assert.assertEquals(nodes.getNodeLabel().size(), 2); String searchPathForLabels = nodes.getSearchPath(); for (org.bidib.wizard.migration.schema.nodes.NodeLabel nodeLabel : nodes.getNodeLabel()) { LOGGER.info("Collect labels for node: {}", nodeLabel); if (Bidib2LabelMigrator.class.getName().equals(nodes.getMigratorClass())) { Bidib2LabelMigrator.moveSourceFileToBackupDir(nodes.getSearchPath(), nodeLabel.getUniqueId());
public Nodes withNodeLabel(NodeLabel... values) { if (values!= null) { for (NodeLabel value: values) { getNodeLabel().add(value); } } return this; }
@Override protected Nodes performFindAllNodesInWizardLabels(String fileName, String transformationXSL, String searchpath) { Nodes nodes = null; try { nodes = super.performFindAllNodesInWizardLabels(fileName, transformationXSL, searchpath); if (nodes != null) { nodes.setMigrationXsl(transformationXSL); } } catch (UnexpectedCharacterException ex) { LOGGER.warn("Perform find nodes with transformation failed due to an unexpected character.", ex); nodes = super.performFindAllNodesInWizardLabels(fileName, INPUT3A_XSL, searchpath); if (nodes != null) { nodes.setMigrationXsl(INPUT3A_XSL); } } return nodes; }
@Test public void findAllNodesInWizardLabelsTest() { URL url = OldWizardLabelMigratorTest.class.getResource(DATA1_XML); Assert.assertNotNull(url); String searchPath = url.getPath(); // get the path only searchPath = FilenameUtils.getFullPath(searchPath); LOGGER.info("Prepared search path: {}", searchPath); OldWizardLabelMigrator migrator = new OldWizardLabelMigrator(); Nodes nodes = migrator.findAllNodesInWizardLabels(searchPath); Assert.assertNotNull(nodes); Assert.assertNotNull(nodes.getNodeLabel()); List<org.bidib.wizard.migration.schema.nodes.NodeLabel> nodeLabels = nodes.getNodeLabel(); LOGGER.info("Current nodeLabels: {}", nodeLabels); Assert.assertEquals(nodeLabels.size(), 3); }
@Test public void findAllNodesInWizardLabelsTest() { URL url = WizardLabelMigratorTest.class.getResource(DATA3_XML); Assert.assertNotNull(url); String searchPath = url.getPath(); // get the path only searchPath = FilenameUtils.getFullPath(searchPath); LOGGER.info("Prepared search path: {}", searchPath); WizardLabelMigrator migrator = new WizardLabelMigrator(); Nodes nodes = migrator.findAllNodesInWizardLabels(searchPath); Assert.assertNotNull(nodes); Assert.assertNotNull(nodes.getNodeLabel()); List<org.bidib.wizard.migration.schema.nodes.NodeLabel> nodeLabels = nodes.getNodeLabel(); LOGGER.info("Current nodeLabels: {}", nodeLabels); Assert.assertEquals(nodeLabels.size(), 6); }
@Test public void findAllNodesInWizardLightPortLabelsTest() { URL url = OldWizardLabelMigratorTest.class.getResource(DATA1_XML); Assert.assertNotNull(url); String searchPath = url.getPath(); // get the path only searchPath = FilenameUtils.getFullPath(searchPath); LOGGER.info("Prepared search path: {}", searchPath); OldWizardLabelMigrator migrator = new OldWizardLabelMigrator(); Nodes nodes = migrator.performFindAllNodesInWizardLabels("LightPortLabels", OldWizardLabelMigrator.INPUT5_XSL, searchPath); Assert.assertNotNull(nodes); Assert.assertNotNull(nodes.getNodeLabel()); List<org.bidib.wizard.migration.schema.nodes.NodeLabel> nodeLabels = nodes.getNodeLabel(); LOGGER.info("Current nodeLabels: {}", nodeLabels); Assert.assertEquals(nodeLabels.size(), 2); }