2 * Copyright © 2023 Fujitsu Network Communications, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.servicehandler.catalog;
10 import java.util.concurrent.ExecutionException;
11 import java.util.concurrent.TimeUnit;
12 import java.util.concurrent.TimeoutException;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.transportpce.common.Timeouts;
15 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev211210.operational.mode.catalog.OpenroadmOperationalModes;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.operational.mode.catalog.rev211210.operational.mode.catalog.SpecificOperationalModes;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OperationalModeCatalog;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Reference;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 public class CatalogDataStoreOperationsImpl implements CatalogDataStoreOperations {
28 private static final Logger LOG = LoggerFactory.getLogger(CatalogDataStoreOperationsImpl.class);
30 private NetworkTransactionService networkTransactionService;
33 public CatalogDataStoreOperationsImpl(@Reference NetworkTransactionService networkTransactionService) {
34 this.networkTransactionService = networkTransactionService;
38 * Store OpenroadmOperationalModes object in the config data store.
41 public void addOpenroadmOperationalModesToCatalog(OpenroadmOperationalModes objToSave) {
42 LOG.info("Inside addOpenroadmOperationalModesToCatalog method of CatalogDataStoreOperationsImpl");
44 InstanceIdentifier<OpenroadmOperationalModes> instanceIdentifier =
45 InstanceIdentifier.create(OperationalModeCatalog.class).child(OpenroadmOperationalModes.class);
46 networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, instanceIdentifier , objToSave);
47 networkTransactionService.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
48 } catch (TimeoutException | InterruptedException | ExecutionException e) {
49 LOG.warn("Warning addOpenroadmOperationalModesToCatalog CatalogDataStoreOperationsImpl");
54 * Store SpecificOperationalModes object in the config data store.
57 public void addSpecificOperationalModesToCatalog(SpecificOperationalModes objToSave) {
58 LOG.info("Inside addSpecificOperationalModesToCatalog method of CatalogDataStoreOperationsImpl");
60 InstanceIdentifier<SpecificOperationalModes> instanceIdentifier = InstanceIdentifier
61 .create(OperationalModeCatalog.class).child(SpecificOperationalModes.class);
62 networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, instanceIdentifier , objToSave);
63 networkTransactionService.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
64 } catch (TimeoutException | InterruptedException | ExecutionException e) {
65 LOG.warn("Warning addSpecificOperationalModesToCatalog CatalogDataStoreOperationsImpl");