0% found this document useful (0 votes)
27 views

00 Changes

The document describes code for adding product identifier columns like Vendor Part Number (VP) and Buyer Part Number (BP) to a report. It extracts the product codes for each item, groups them by type, and generates new items with either the VP or BP value populated based on the type, while removing the original product codes details. When writing report headers, it will iterate through chunks and items, generating separate items for each VP and BP value before removing the product codes information.

Uploaded by

test
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

00 Changes

The document describes code for adding product identifier columns like Vendor Part Number (VP) and Buyer Part Number (BP) to a report. It extracts the product codes for each item, groups them by type, and generates new items with either the VP or BP value populated based on the type, while removing the original product codes details. When writing report headers, it will iterate through chunks and items, generating separate items for each VP and BP value before removing the product codes information.

Uploaded by

test
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

GenericOrdersDataset

contact -215 line


//---- Adding the Product --//
addColumn(new SummaryColumnEssenceBuilder("productSummary")
.displayName("Product Summary")
.objectName(PRODUCT_CODES)
.type(ProductParameter.class).build()
.setMultilineReport(false))
.hideFromColumnSelection(true);
addColumn(new StringColumnEssenceBuilder("productTypee")
.displayName("Product Type")
.objectName(PRODUCT_CODES)
.field("productCodesSummary.productCodes.type").build())
.groupable(true).displayColumn("productSummary")
.hideFromColumnSelection(true);
addColumn(new EnumColumnEssenceBuilder("productValuee")
.objectName(PRODUCT_CODES)
.field("productCodesSummary.productCodes.value")
.displayName("Product Value").build().groupable(true)
.allowMultipleValues(true).displayColumn("ProductSummary")
.hideFromColumnSelection(true).possibleValues(
Arrays.stream(ProductRepresentationType.values())
.map(t -> new EnumValue(t.getDisplayName(),
t.getDisplayName()))
.collect(Collectors.toList())));

addColumn(new StringColumn("VP", "VP",


"Vendor Part Number", false, true).hideFromColumnSelection(true));
addColumn(new StringColumn("BP", "BP",
"Buyer Part Number", false, true).hideFromColumnSelection(true));
//-------------------------//

ReportManager3000.java
709

mapper.writeHeaders(first);
//-- code for product identifier
if (orderedColumns.contains("VP")) {
ArrayList<Map<String, Object>> newList = new ArrayList<>();
for (ReportDataGroupChunk chunk : chunks) {
for (Map<String, Object> item : chunk.getItems()) {

List<Map<String, String>> productCodes = (List<Map<String,


String>>) item.get(
"productCodesSummary.productCodes");
//-- For-each loop for iteration
HashMap<String, String> hashMap = new HashMap<>();
for (Map<String, String> mp : productCodes) {
hashMap.put(mp.get("value"), mp.get("type"));
}

Map<String, List<String>> prodMap =


hashMap.entrySet().stream().collect(Collectors.groupingBy(
Map.Entry::getValue,
Collectors.mapping(Map.Entry::getKey, Collectors.toList())));

//-- Start VP put --//


System.out.println("prodmap get vp -- " +
prodMap.get("VP"));
if (prodMap.get("VP") != null) {
for (String oneVP : prodMap.get("VP")) {
log.info("one each VP -- " + oneVP);
LinkedHashMap<String, Object> newItem = new
LinkedHashMap<>();
newItem.putAll(item);
newItem.remove("productCodesSummary.productCodes");
newItem.remove("productCodesSummary");
newItem.put("VP", oneVP);
newItem.put("BP", "");
newList.add(newItem);
}
}
//-- End VP put ---//

//-- Start BP put --//


if (prodMap.get("BP") != null) {
for (String oneBP : prodMap.get("BP")) {
log.info("one each BP -- " + oneBP);
LinkedHashMap<String, Object> newItem = new
LinkedHashMap<>();
newItem.putAll(item);
newItem.remove("productCodesSummary.productCodes");
newItem.remove("productCodesSummary");
newItem.put("VP", "");
newItem.put("BP", oneBP);
newList.add(newItem);
}
}
//-- End BP put ---//

//-- code end


// -- end code of pi --//
}
chunk.setItems(newList);
//}
//for (ReportDataGroupChunk chunk : chunks) {
for (Map<String, Object> newItm : chunk.getItems()) {
mapper.map(newItm, orderedColumns);
}
}
orderedColumns.remove("productSummary");
} else {
// -- If not Order Identifier
for (ReportDataGroupChunk chunk : chunks) {
for (Map<String, Object> newItm : chunk.getItems()) {
mapper.map(newItm, orderedColumns);
}
}
}
mapper.appendAggregations(groupName, group.getAggregations());

You might also like