Skip to content

Commit

Permalink
Using sector framework name from config
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento committed Apr 17, 2024
1 parent 7fb2b8d commit 85471ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public SBApiResponse getSectors() {

StringBuilder strUrl = new StringBuilder(extServerProperties.getKmBaseHost());
strUrl.append(extServerProperties.getKmFrameworkTermSearchPath()).append("?framework=")
.append(extServerProperties.getTaxonomyFrameWorkName()).append("&category=")
.append(extServerProperties.getSectorFrameworkName()).append("&category=")
.append(extServerProperties.getSectorCategoryName());

Map<String, Object> termResponse = outboundRequestHandlerServiceImpl.fetchResultUsingPost(strUrl.toString(),
Expand Down Expand Up @@ -163,7 +163,7 @@ public SBApiResponse readSector(String sectorId) {
try {
StringBuilder strUrl = new StringBuilder(extServerProperties.getKmBaseHost());
strUrl.append(extServerProperties.getKmFrameworkTermReadPath()).append("/").append(sectorId).append("?framework=")
.append(extServerProperties.getTaxonomyFrameWorkName()).append("&category=")
.append(extServerProperties.getSectorFrameworkName()).append("&category=")
.append(extServerProperties.getSectorCategoryName());

Map<String, Object> sectorMap = new HashMap<String, Object>();
Expand Down Expand Up @@ -214,7 +214,7 @@ public SBApiResponse createSector(Map<String, Object> request) {
// Resource is not found... we can create sector.
reqBody.put(Constants.CODE, name);
Map<String, Object> parentObj = new HashMap<>();
parentObj.put(Constants.IDENTIFIER, extServerProperties.getTaxonomyFrameWorkName() + "_" + extServerProperties.getSectorCategoryName());
parentObj.put(Constants.IDENTIFIER, extServerProperties.getSectorFrameworkName() + "_" + extServerProperties.getSectorCategoryName());
reqBody.put(Constants.PARENTS, Arrays.asList(parentObj));
Map<String, Object> termReq = new HashMap<String, Object>();
termReq.put(Constants.TERM, reqBody);
Expand All @@ -223,7 +223,7 @@ public SBApiResponse createSector(Map<String, Object> request) {

StringBuilder strUrl = new StringBuilder(extServerProperties.getKmBaseHost());
strUrl.append(extServerProperties.getKmFrameworkTermCreatePath()).append("?framework=")
.append(extServerProperties.getTaxonomyFrameWorkName()).append("&category=")
.append(extServerProperties.getSectorFrameworkName()).append("&category=")
.append(extServerProperties.getSectorCategoryName());
Map<String, Object> termResponse = outboundRequestHandlerServiceImpl.fetchResultUsingPost(strUrl.toString(),
createReq, null);
Expand Down Expand Up @@ -284,15 +284,15 @@ public SBApiResponse createSubSector(Map<String, Object> request) {
termReq.put(Constants.NAME, name);

Map<String, Object> parentObj = new HashMap<>();
parentObj.put(Constants.IDENTIFIER, extServerProperties.getTaxonomyFrameWorkName() + "_" + extServerProperties.getSectorCategoryName() + "_" + id);
parentObj.put(Constants.IDENTIFIER, extServerProperties.getSectorFrameworkName() + "_" + extServerProperties.getSectorCategoryName() + "_" + id);
termReq.put(Constants.PARENTS, Arrays.asList(parentObj));
requestBody.put(Constants.TERM, termReq);
Map<String, Object> createReq = new HashMap<String, Object>();
createReq.put(Constants.REQUEST, requestBody);

StringBuilder strUrl = new StringBuilder(extServerProperties.getKmBaseHost());
strUrl.append(extServerProperties.getKmFrameworkTermCreatePath()).append("?framework=")
.append(extServerProperties.getTaxonomyFrameWorkName()).append("&category=")
.append(extServerProperties.getSectorFrameworkName()).append("&category=")
.append(extServerProperties.getSectorCategoryName());
Map<String, Object> termResponse = outboundRequestHandlerServiceImpl.fetchResultUsingPost(strUrl.toString(),
createReq, null);
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/sunbird/common/util/CbExtServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ public void setRedisWheeboxKey(String redisWheeboxKey) {
@Value("${km.framework.term.create.path}")
private String kmFrameworkTermCreatePath;

@Value("${sector.framework.name}")
private String sectorFrameworkName;

public boolean qListFromCacheEnabled() {
return qListFromCacheEnabled;
}
Expand Down Expand Up @@ -2512,4 +2515,12 @@ public String getKmFrameworkTermCreatePath() {
public void setKmFrameworkTermCreatePath(String kmFrameworkTermCreatePath) {
this.kmFrameworkTermCreatePath = kmFrameworkTermCreatePath;
}

public String getSectorFrameworkName() {
return sectorFrameworkName;
}

public void setSectorFrameworkName(String sectorFrameworkName) {
this.sectorFrameworkName = sectorFrameworkName;
}
}
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ km.framework.term.create.path=v1/framework/term/create
#Taxonomy Framework and Category
igot.taxonomy.framework.name=igot
igot.taxonomy.category.name=Taxonomy
sector.category.name=testsector
sector.framework.name=sector-fw
sector.category.name=sector
sector.category.fields=identifier,code,name,description,appIcon,imgUrl
sub.sector.category.fields=identifier,code,name,description,appIcon

Expand Down

0 comments on commit 85471ea

Please sign in to comment.