Skip to content

Commit

Permalink
feat : setting FundHouse Name on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Jan 11, 2024
1 parent 977c79a commit 3c93ea9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
19 changes: 11 additions & 8 deletions src/main/java/com/learning/mfscreener/config/Initializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;

@Component
Expand All @@ -36,15 +37,17 @@ public void run(String... args) throws IOException {
String allNAVs = restTemplate.getForObject(AppConstants.AMFI_WEBSITE_LINK, String.class);
Reader inputString = new StringReader(Objects.requireNonNull(allNAVs));
try (BufferedReader br = new BufferedReader(inputString)) {
String fileRead = br.readLine();
String lineValue = br.readLine();
for (int i = 0; i < 4; ++i) {
fileRead = br.readLine();
lineValue = br.readLine();
}
while (fileRead != null) {
String amc = lineValue;
while (lineValue != null) {
int check = 0;
final String[] tokenize = fileRead.split(AppConstants.SEPARATOR);
final String[] tokenize = lineValue.split(AppConstants.SEPARATOR);
if (tokenize.length == 1) {
check = 1;
amc = lineValue;
}
if (check == 0) {
final String schemecode = tokenize[0];
Expand All @@ -54,12 +57,12 @@ public void run(String... args) throws IOException {
final String nav = tokenize[4];
final String date = tokenize[5];
final MFSchemeDTO tempObj =
new MFSchemeDTO(Long.valueOf(schemecode), payout, schemename, nav, date);
new MFSchemeDTO(amc, Long.valueOf(schemecode), payout, schemename, nav, date);
chopArrayList.add(tempObj);
}
fileRead = br.readLine();
if ("".equals(fileRead)) {
fileRead = br.readLine();
lineValue = br.readLine();
if (!StringUtils.hasText(lineValue)) {
lineValue = br.readLine();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface MfSchemeDtoToEntityMapper extends Converter<MFSchemeDTO, MFSche
@Mapping(target = "schemeNameAlias", ignore = true)
@Mapping(target = "lastModifiedDate", ignore = true)
@Mapping(target = "lastModifiedBy", ignore = true)
@Mapping(target = "fundHouse", ignore = true)
@Mapping(target = "fundHouse", source = "amc")
@Mapping(target = "createdDate", ignore = true)
@Mapping(target = "createdBy", ignore = true)
@Mapping(target = "payOut", source = "payout")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public interface MfSchemeEntityToDtoMapper extends Converter<MFSchemeEntity, MFS
@Mapping(target = "nav", ignore = true)
@Mapping(target = "schemeCode", source = "schemeId")
@Mapping(target = "payout", source = "payOut")
@Mapping(target = "amc", source = "fundHouse")
@Override
MFSchemeDTO convert(MFSchemeEntity mfSchemeEntity);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/learning/mfscreener/models/MFSchemeDTO.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Licensed under Apache-2.0 2021-2022. */
/* Licensed under Apache-2.0 2021-2024. */
package com.learning.mfscreener.models;

import java.io.Serializable;

public record MFSchemeDTO(Long schemeCode, String payout, String schemeName, String nav, String date)
public record MFSchemeDTO(String amc, Long schemeCode, String payout, String schemeName, String nav, String date)
implements Serializable {
public MFSchemeDTO withNavAndDate(String navValue, String navDate) {
return new MFSchemeDTO(schemeCode(), payout(), schemeName(), navValue, navDate);
return new MFSchemeDTO(amc(), schemeCode(), payout(), schemeName(), navValue, navDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ void mergeList(NavResponse navResponse, MFSchemeEntity mfSchemeEntity, Long sche
entity.setSchemeCategory(meta.schemeCategory());
return this.mfSchemeTypeRepository.save(entity);
});
mfSchemeEntity.setFundHouse(meta.fundHouse());
// As fund house is set at initializing, removing from here
// mfSchemeEntity.setFundHouse(meta.fundHouse());
mfschemeTypeEntity.addMFScheme(mfSchemeEntity);
try {
this.mfSchemeRepository.save(mfSchemeEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ResponseEntity<PortfolioResponse> getPortfolio(
@Parameter(description = "Pan of the end User", name = "pan", in = ParameterIn.PATH, example = "ABCDE1234F")
String panNumber,
@Parameter(
description = "get portfolio value for given date",
description = "get portfolio value for given date (yyyy-MM-dd) format",
in = ParameterIn.QUERY,
example = "2022-12-31",
required = true)
Expand Down

0 comments on commit 3c93ea9

Please sign in to comment.