- public String getGnpyResponse(List<Elements> elementsList, List<Connections> connectionsList,
- List<PathRequest> pathRequestList, List<Synchronization> synchronizationList) throws GnpyException, Exception {
- GnpyApi gnpyApi = new GnpyApiBuilder()
- .setTopologyFile(
- new TopologyFileBuilder().setElements(elementsList).setConnections(connectionsList).build())
- .setServiceFile(
- new ServiceFileBuilder().setPathRequest(pathRequestList).build())
- .build();
- InstanceIdentifier<GnpyApi> idGnpyApi = InstanceIdentifier.builder(GnpyApi.class).build();
- String gnpyJson;
- ServiceDataStoreOperationsImpl sd = new ServiceDataStoreOperationsImpl(networkTransaction);
- gnpyJson = sd.createJsonStringFromDataObject(idGnpyApi, gnpyApi);
- LOG.debug("GNPy Id: {} / json created : {}", idGnpyApi, gnpyJson);
- ConnectToGnpyServer connect = new ConnectToGnpyServer();
- String gnpyJsonModified = gnpyJson
- .replace("gnpy-eqpt-config:", "")
- .replace("gnpy-path-computation-simplified:", "")
- .replace("gnpy-network-topology:", "");
-
- String gnpyResponse = connect.gnpyCnx(gnpyJsonModified);
- return gnpyResponse;
+ public Result getGnpyResponse(List<Elements> elementsList, List<Connections> connectionsList,
+ List<PathRequest> pathRequestList, List<Synchronization> synchronizationList) {
+
+ return gnpyConsumer.computePaths(new RequestBuilder()
+ .setTopology(
+ new TopologyBuilder()
+ .setElements(elementsList.stream().collect(Collectors.toMap(Elements::key, element -> element)))
+ .setConnections(connectionsList).build())
+ .setService(
+ new ServiceBuilder()
+ .setPathRequest(pathRequestList.stream()
+ .collect(Collectors.toMap(PathRequest::key, pathRequest -> pathRequest)))
+ .build())
+ .build());