Skip to content

Commit

Permalink
Merge pull request #31 from anilkumarkammalapalli/termCreate
Browse files Browse the repository at this point in the history
Term create
  • Loading branch information
sivaprakash123 authored Aug 2, 2024
2 parents 3f57b59 + bff0da9 commit 7b78ef4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void generateFrameworkHierarchy(String id) throws Exception {
FrameworkCache.delete(id);
Map<String, Object> frameworkDocument = new HashMap<>();
Map<String, Object> frameworkHierarchy = getHierarchy(node.getIdentifier(), 0, false, true);
TelemetryManager.info("frameworkHierarchy map::: "+frameworkHierarchy);
CategoryCache.setFramework(node.getIdentifier(), frameworkHierarchy);

frameworkDocument.putAll(frameworkHierarchy);
Expand Down Expand Up @@ -101,7 +102,8 @@ private Map<String, Object> getHierarchy(String id, int index, boolean includeMe
throw new ResourceNotFoundException("ERR_DATA_NOT_FOUND", "Data not found with id : " + id,
ResponseCode.RESOURCE_NOT_FOUND);
Node node = (Node) responseNode.get(GraphDACParams.node.name());

String nodeName = (String) node.getMetadata().getOrDefault("code","");
TelemetryManager.info("Processing node ID :: "+nodeName);
Map<String, Object> metadata = node.getMetadata();
String status = (String) metadata.get("status");
if (StringUtils.equalsIgnoreCase("Live", status)) {
Expand Down Expand Up @@ -143,6 +145,7 @@ private Map<String, Object> getHierarchy(String id, int index, boolean includeMe
ConvertGraphNode.getRelationDefinitionMaps(definition, inRelDefMap, outRelDefMap);
List<Relation> outRelations = node.getOutRelations();
if (null != outRelations && !outRelations.isEmpty()) {
TelemetryManager.info("Node (ID: " + id + ") has " + outRelations.size() + " outgoing relations.");
for (Relation relation : outRelations) {
String type = relation.getRelationType();
String key = type + relation.getEndNodeObjectType();
Expand All @@ -151,6 +154,8 @@ private Map<String, Object> getHierarchy(String id, int index, boolean includeMe
if (relData == null) {
relData = new ArrayList<Map<String, Object>>();
data.put(title, relData);
TelemetryManager.info("Node " + nodeName + " (ID: " + id + ") has outgoing relation to node " +
relation.getEndNodeId() + " with type " + relation.getRelationType());
if ("hasSequenceMember".equalsIgnoreCase(type))
sortKeys.add(title);
}
Expand All @@ -177,7 +182,8 @@ private Map<String, Object> getHierarchy(String id, int index, boolean includeMe
}
}
}

String jsonData = mapper.writeValueAsString(data);
TelemetryManager.info("printing Hierarchy data: "+jsonData);
return data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.sunbird.graph.dac.model.Node;
import org.sunbird.graph.dac.model.Relation;
import org.springframework.stereotype.Component;
import org.sunbird.telemetry.logger.TelemetryManager;

/**
* @author pradyumna
Expand All @@ -36,6 +37,7 @@ public class TermManagerImpl extends BaseFrameworkManager implements ITermManage
@SuppressWarnings("unchecked")
@Override
public Response createTerm(String scopeId, String category, Request req) throws Exception {
TelemetryManager.info("frameworkTermCreate function started ::: ");
List<Map<String, Object>> requestList = getRequestData(req);
if (null == req.get(TermEnum.term.name()) || null == requestList || requestList.isEmpty())
throw new ClientException("ERR_INVALID_TERM_OBJECT", "Invalid Request");
Expand All @@ -53,7 +55,7 @@ public Response createTerm(String scopeId, String category, Request req) throws
} else {
validateCategoryId(categoryId);
}

TelemetryManager.info("frameworkTermCreate function categoryId::: "+categoryId);
int codeError = 0;
int serverError = 0;
String id = null;
Expand All @@ -79,6 +81,7 @@ public Response createTerm(String scopeId, String category, Request req) throws
identifiers.add((String) resp.getResult().get("node_id"));
} else {
if ((StringUtils.equalsIgnoreCase("CONSTRAINT_VALIDATION_FAILED", resp.getParams().getErr()))) {
TelemetryManager.info("frameworkTermCreate function CONSTRAINT_VALIDATION_FAILED:::"+resp.getParams().getErr());
codeError += 1;
} else {
serverError += 1;
Expand All @@ -89,6 +92,7 @@ public Response createTerm(String scopeId, String category, Request req) throws
codeError += 1;
}
}
TelemetryManager.info("frameworkTermCreate function (codeError: " + codeError + ") has serverError: " + serverError + " identifiers "+identifiers +"requestsize "+requestList.size());
return createResponse(codeError, serverError, identifiers, requestList.size());
}

Expand Down

0 comments on commit 7b78ef4

Please sign in to comment.