GuidedDTDRLPersistence { void doMetadata(List<BaseColumn> allColumns, List<MetadataCol52> metadataCols, List<DTCellValue52> row, RuleModel rm) { List<RuleMetadata> metadataList = new ArrayList<RuleMetadata>(); for (int j = 0; j < metadataCols.size(); j++) { MetadataCol52 meta = metadataCols.get(j); int index = allColumns.indexOf(meta); final DTCellValue52 dcv = row.get(index); String cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv); if (validateMetadataCell(cell)) { metadataList.add(new RuleMetadata(meta.getMetadata(), cell)); } } if (metadataList.size() > 0) { rm.metadataList = metadataList.toArray(new RuleMetadata[metadataList.size()]); } }  static GuidedDTDRLPersistence getInstance(); String marshal(final GuidedDecisionTable52 originalDTable);  }
@Test public void testMetaData() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); String[] row = new String[]{"1", "desc", "bar", ""}; List<BaseColumn> allColumns = new ArrayList<BaseColumn>(); allColumns.add(new RowNumberCol52()); allColumns.add(new DescriptionCol52()); List<MetadataCol52> metadataCols = new ArrayList<MetadataCol52>(); RuleModel rm = new RuleModel(); RuleMetadata[] orig = rm.metadataList; p.doMetadata(allColumns, metadataCols, DataUtilities.makeDataRowList(row), rm); assertSame(orig, rm.metadataList); MetadataCol52 col1 = new MetadataCol52(); col1.setMetadata("foo"); MetadataCol52 col2 = new MetadataCol52(); col2.setMetadata("foo2"); metadataCols.add(col1); metadataCols.add(col2); allColumns.addAll(metadataCols); p.doMetadata(allColumns, metadataCols, DataUtilities.makeDataRowList(row), rm); assertEquals(1, rm.metadataList.length); assertEquals("foo", rm.metadataList[0].getAttributeName()); assertEquals("bar", rm.metadataList[0].getValue()); row = new String[]{"1", "desc", "bar1", "bar2"}; p.doMetadata(allColumns, metadataCols, DataUtilities.makeDataRowList(row), rm); assertEquals(2, rm.metadataList.length); assertEquals("foo", rm.metadataList[0].getAttributeName()); assertEquals("bar1", rm.metadataList[0].getValue()); assertEquals("foo2", rm.metadataList[1].getAttributeName()); assertEquals("bar2", rm.metadataList[1].getValue()); }