ontology-engine/graph-core/src/main/java/org/sunbird/graph/validator/NodeValidator.java
public static Future<Map<String, Node>> validate(String graphId, List<String> identifiers) {
        List<Map<String, Object>> result;
        Future<List<Node>> nodes = getDataNodes(graphId, identifiers);
        CompletionStage<Map<String, Node>> cs = FutureConverters.toJava(nodes).thenApply(dataNodes -> {
            Map<String, Node> relationNodes = new HashMap<>();
            if (dataNodes.size() != identifiers.size()) {
                List<String> invalidIds = identifiers.stream().filter(id -> dataNodes.stream().noneMatch(node -> node.getIdentifier().equals(id)))
                        .collect(Collectors.toList());
                throw new ResourceNotFoundException(GraphEngineErrorCodes.ERR_INVALID_NODE.name(), "Node Not Found With Identifier " + invalidIds);
            } else {
                relationNodes = dataNodes.stream().collect(Collectors.toMap(node -> node.getIdentifier(), node -> node));
                return relationNodes;
            }
        });

        return FutureConverters.toScala(cs);
    }
/**
     * This method validates whether given identifiers exist in the given graph or not.
     * @param graphId
     * @param identifiers
     * @return List<Node>
     */
This method validates whether given identifiers exist in the given graph or not.
@param graphId
@param identifiers
@return List
This method validates whether given identifiers exist in the given graph or not . @param graphId @param identifiers @return List
public static Future<Map<String, Node>> validate(String graphId, List<String> identifiers) {
        List<Map<String, Object>> result;
        Future<List<Node>> nodes = getDataNodes(graphId, identifiers);
        CompletionStage<Map<String, Node>> cs = FutureConverters.toJava(nodes).thenApply(dataNodes -> {
            Map<String, Node> relationNodes = new HashMap<>();
            if (dataNodes.size() != identifiers.size()) {
                List<String> invalidIds = identifiers.stream().filter(id -> dataNodes.stream().noneMatch(node -> node.getIdentifier().equals(id)))
                        .collect(Collectors.toList());
                throw new ResourceNotFoundException(GraphEngineErrorCodes.ERR_INVALID_NODE.name(), "Node Not Found With Identifier " + invalidIds);
            } else {
                relationNodes = dataNodes.stream().collect(Collectors.toMap(node -> node.getIdentifier(), node -> node));
                return relationNodes;
            }
        });
        return FutureConverters.toScala(cs);
    }
public static Future < Map < String , Node > > validate ( String graphId , List < String > identifiers ) { List < Map < String , Object > > result ; Future < List < Node > > nodes = getDataNodes ( graphId , identifiers ) ; CompletionStage < Map < String , Node > > cs = FutureConverters . toJava ( nodes ) . thenApply ( dataNodes -> { Map < String , Node > relationNodes = new HashMap < > ( ) ; if ( dataNodes . size ( ) != identifiers . size ( ) ) { List < String > invalidIds = identifiers . stream ( ) . filter ( id -> dataNodes . stream ( ) . noneMatch ( node -> node . getIdentifier ( ) . equals ( id ) ) ) . collect ( Collectors . toList ( ) ) ; throw new ResourceNotFoundException ( GraphEngineErrorCodes . ERR_INVALID_NODE . name ( ) , "Node Not Found With Identifier " + invalidIds ) ; } else { relationNodes = dataNodes . stream ( ) . collect ( Collectors . toMap ( node -> node . getIdentifier ( ) , node -> node ) ) ; return relationNodes ; } } ) ; return FutureConverters . toScala ( cs ) ; }
This method validates whether given identifiers exist in the given graph or not.
This method validates whether given identifiers exist in the given graph or not .