Skip to content

Commit

Permalink
[MODEXPW-529] Fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Dec 13, 2024
1 parent eb25f26 commit ff8bbab
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,33 @@ public String convertForExport(List<CompositePurchaseOrder> compPOs, List<Piece>
EDIOutputFactory factory = EDIOutputFactory.newFactory();
factory.setProperty(EDIOutputFactory.PRETTY_PRINT, true);

EDIStreamWriter writer = factory.createEDIStreamWriter(stream);

// Count of messages (one message per purchase order)
int messageCount = 0;
writer.startInterchange();
writeStartFile(writer);

EdiFileConfig ediFileConfig = new EdiFileConfig();
ediFileConfig.setFileId(StringUtils.right(jobName, 14));
ediFileConfig.setLibEdiCode(ediExportConfig.getEdiConfig().getLibEdiCode());
ediFileConfig.setLibEdiType(ediExportConfig.getEdiConfig().getLibEdiType().getValue().substring(0, 3));
ediFileConfig.setVendorEdiCode(ediExportConfig.getEdiConfig().getVendorEdiCode());
ediFileConfig.setVendorEdiType(ediExportConfig.getEdiConfig().getVendorEdiType().getValue().substring(0, 3));

writeInterchangeHeader(writer, ediFileConfig);

var poLineIdToPieces = pieces.stream().collect(groupingBy(Piece::getPoLineId));
// Purchase orders
for (CompositePurchaseOrder compPO : compPOs) {
compOrderEdiConverter.convertPOtoEdifact(writer, compPO, poLineIdToPieces, ediFileConfig);
messageCount++;
try (EDIStreamWriter writer = factory.createEDIStreamWriter(stream)) {
// Count of messages (one message per purchase order)
int messageCount = 0;
writer.startInterchange();
writeStartFile(writer);

EdiFileConfig ediFileConfig = new EdiFileConfig();
ediFileConfig.setFileId(StringUtils.right(jobName, 14));
ediFileConfig.setLibEdiCode(ediExportConfig.getEdiConfig().getLibEdiCode());
ediFileConfig.setLibEdiType(ediExportConfig.getEdiConfig().getLibEdiType().getValue().substring(0, 3));
ediFileConfig.setVendorEdiCode(ediExportConfig.getEdiConfig().getVendorEdiCode());
ediFileConfig.setVendorEdiType(ediExportConfig.getEdiConfig().getVendorEdiType().getValue().substring(0, 3));

writeInterchangeHeader(writer, ediFileConfig);

var poLineIdToPieces = pieces.stream().collect(groupingBy(Piece::getPoLineId));
// Purchase orders
for (CompositePurchaseOrder compPO : compPOs) {
compOrderEdiConverter.convertPOtoEdifact(writer, compPO, poLineIdToPieces, ediFileConfig);
messageCount++;
}

writeInterchangeFooter(writer, ediFileConfig.getFileId(), messageCount);
writer.endInterchange();
return stream.toString();
}

writeInterchangeFooter(writer, ediFileConfig.getFileId(), messageCount);
writer.endInterchange();
writer.close();

return stream.toString();
}

// Start of file - Can contain multiple order messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public abstract class AbstractCsvConverter<T> {
private final DelimitedLineAggregator<String> lineAggregator;
private final String delimiter;

public AbstractCsvConverter() {
protected AbstractCsvConverter() {
this(COMMA);
}

public AbstractCsvConverter(String delimiter) {
protected AbstractCsvConverter(String delimiter) {
this.delimiter = delimiter;
this.lineAggregator = new DelimitedLineAggregator<>();
lineAggregator.setDelimiter(delimiter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
@AllArgsConstructor
public enum ClaimCsvFields implements ExtractableField<Pair<CompositePoLine, Piece>, String> {

POL_NUMBER("POL number", (pair) -> pair.getKey().getPoLineNumber()),
ORDER_NUMBER("Vendor order number", (pair) -> getVendorOrderNumber(pair.getKey())),
ACCOUNT_NUMBER("Account number", (pair) -> getVendorAccountNumber(pair.getKey())),
TITLE("Title from piece", (pair) -> "CHANGEME"), // FIXME: piece.titleId | poLine.titleOrPackage | title from inventory by piece.titleId
DISPLAY_SUMMARY("Display summary", (pair) -> pair.getValue().getDisplaySummary()),
CHRONOLOGY("Chronology", (pair) -> pair.getValue().getChronology()),
ENUMERATION("Enumeration", (pair) -> pair.getValue().getEnumeration()),
QUANTITY("Quantity", (pair) -> "CHANGEME"); // FIXME: implement quantity extraction
POL_NUMBER("POL number", pair -> pair.getKey().getPoLineNumber()),
ORDER_NUMBER("Vendor order number", pair -> getVendorOrderNumber(pair.getKey())),
ACCOUNT_NUMBER("Account number", pair -> getVendorAccountNumber(pair.getKey())),
TITLE("Title from piece", pair -> "CHANGEME"), // FIXME: piece.titleId | poLine.titleOrPackage | title from inventory by piece.titleId
DISPLAY_SUMMARY("Display summary", pair -> pair.getValue().getDisplaySummary()),
CHRONOLOGY("Chronology", pair -> pair.getValue().getChronology()),
ENUMERATION("Enumeration", pair -> pair.getValue().getEnumeration()),
QUANTITY("Quantity", pair -> "CHANGEME"); // FIXME: implement quantity extraction

@Getter
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void getInstanceIdByHoldingShouldReturnCorrectInstanceId() throws JsonProcessing
}

@Test
void getInstanceIdByHoldingShouldReturnCorrectEmptyStringWhenNull() throws JsonProcessingException {
void getInstanceIdByHoldingShouldReturnCorrectEmptyStringWhenNull() {
String actual = holdingService.getInstanceIdByHolding(null);
assertTrue(actual.isEmpty());
}
Expand Down

0 comments on commit ff8bbab

Please sign in to comment.