Skip to content

MISO4204-201810/graph-example-design-patterns

Repository files navigation

Graph example whit design patterns

Method to choose (set) the implementation of the factory

    @RequestMapping(value = "/api/graph/{graphType}", method = RequestMethod.PUT)
    @ResponseBody
    public IGraph setTypeGraph(@PathVariable("graphType") GraphType graphType) {
        this._graphFactory = this.getGraphFactory(graphType);
        this.graph = _graphFactory.createGraph();
        return this.graph;
    }

Method to get the graph data

    @RequestMapping(value = "/api/graph", method = RequestMethod.GET)
    @ResponseBody
    public IGraph getGraph() {
        return this.graph;
    }

Method to choose the search strategy

    @RequestMapping(value = "/api/graph/node/{nodeId}", method = RequestMethod.GET)
    @ResponseBody
    public INode findNode(@PathVariable("nodeId") String nodeId, @RequestParam FindType findType) {
        IFindStrategy findStrategy = this.getFindStrategy(findType);
        return findStrategy.findNode(nodeId);
    }

Method to add Node to the graph data

    @RequestMapping(value = "/api/graph/node", method = RequestMethod.PUT)
    @ResponseBody
    public INode addNode() {
        INode node = this._graphFactory.createNode();
        this.graph.addNode(node);
        return node;
    }

Method to add Link to the graph data

    @RequestMapping(value = "/api/graph/link", method = RequestMethod.PUT)
    @ResponseBody
    public ILink addLink() {
        ILink link = this._graphFactory.createLink();
        this.graph.addLink(link);
        return link;
    }

https://github.com/MISO4204-201810/graph-example-design-patterns/blob/master/SPL%20de%20Gr%C3%A1fos.jpeg