@Test public void testConvertFromSingleItemIndexingMessage() throws Exception { RelatedItemIndexingMessageConverter converter = getConverter(); RelatedItemIndexingMessage message = getIndexingMessageWithOneRelatedItem(); RelatedItem[] products = converter.convertFrom(message); assertEquals("Should only have found a single product",1,products.length); RelatedItem product = products[0]; assertEquals(DATE, product.getDate()); assertEquals("1",new String(product.getId())); assertEquals("the related product should have 3 properties, two inherited, one for itself",3,product.getAdditionalProperties().getNumberOfProperties()); Map<String,String> props = new HashMap<String,String>(); product.getAdditionalProperties().convertTo(props); assertEquals(SITE, props.get("site")); assertEquals(CHANNEL,props.get("channel")); assertEquals(DEPARTMENT,props.get("department")); }
public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); RelatedItem[] convertFrom(RelatedItemIndexingMessage message); static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length); }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public RelatedItem[] convertFrom(RelatedItemIndexingMessage message) { RelatedItemSet items = message.getRelatedItems(); int numberOfRelatedItems = items.getNumberOfRelatedItems(); RelatedItem[] relatedItems = new RelatedItem[numberOfRelatedItems]; RelatedItemInfo[][] idLists = relatedIds(items.getListOfRelatedItemInfomation(), items.getNumberOfRelatedItems()); int length = numberOfRelatedItems-1; for(int i =0;i<numberOfRelatedItems;i++) { RelatedItemInfo id = idLists[i][length]; relatedItems[i] = createRelatedItem(message, id, idLists[i], message.getIndexingMessageProperties()); } return relatedItems; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); RelatedItem[] convertFrom(RelatedItemIndexingMessage message); static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length);  }