diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2020-09-04 19:16:43 +0100 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2020-09-04 19:19:41 +0100 |
commit | 27d773cb05051ccc7d967434421aba189a0ae8b5 (patch) | |
tree | 9d791907a26978c4e4c708ff0cbeb4cdfd5f5eb1 /so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main | |
parent | 21a476895dc40402dced615cb0f1b112b1796355 (diff) |
Adding entities and repositories for
NS Instantiation
Change-Id: Id7cb2452a8821969ebec5c3f8148f292ded9812e
Issue-ID: SO-3194
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main')
4 files changed, 144 insertions, 4 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java new file mode 100644 index 0000000000..696c7be5dd --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NSLcmOpOccRepository.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.springframework.data.repository.CrudRepository; +import java.util.Optional; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * @author mukeshsharma(mukeshsharma@est.tech) + */ +public interface NSLcmOpOccRepository extends CrudRepository<NsLcmOpOcc, String> { + + Optional<NsLcmOpOcc> findById(final String id); +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobStatusRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobStatusRepository.java new file mode 100644 index 0000000000..c3fe469ff6 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoJobStatusRepository.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus; +import org.springframework.data.repository.CrudRepository; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public interface NfvoJobStatusRepository extends CrudRepository<NfvoJobStatus, Integer> { +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java new file mode 100644 index 0000000000..de14d43de4 --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/repository/NfvoNfInstRepository.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database.repository; + +import java.util.List; +import java.util.Optional; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.springframework.data.repository.CrudRepository; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * @author mukeshsharma(mukeshsharma@est.tech) + */ +public interface NfvoNfInstRepository extends CrudRepository<NfvoNfInst, String> { + + Optional<NfvoNfInst> findByNfInstId(final String nfInstId); + + List<NfvoNfInst> findByNsInstNsInstId(final String nsInstId); + + List<NfvoNfInst> findByNsInstNsInstIdAndName(final String nsInstId, final String name); +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java index 420d916014..254a3698c9 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java @@ -19,10 +19,15 @@ */ package org.onap.so.etsi.nfvo.ns.lcm.database.service; +import java.util.List; import java.util.Optional; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NSLcmOpOccRepository; import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoJobRepository; +import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNfInstRepository; import org.onap.so.etsi.nfvo.ns.lcm.database.repository.NfvoNsInstRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,11 +47,18 @@ public class DatabaseServiceProvider { private final NfvoNsInstRepository nfvoNsInstRepository; + private final NfvoNfInstRepository nfvoNfInstRepository; + + private final NSLcmOpOccRepository nsLcmOpOccRepository; + @Autowired public DatabaseServiceProvider(final NfvoJobRepository nfvoJobRepository, - final NfvoNsInstRepository nfvoNsInstRepository) { + final NfvoNsInstRepository nfvoNsInstRepository, final NfvoNfInstRepository nfvoNfInstRepository, + final NSLcmOpOccRepository nsLcmOpOccRepository) { this.nfvoJobRepository = nfvoJobRepository; this.nfvoNsInstRepository = nfvoNsInstRepository; + this.nfvoNfInstRepository = nfvoNfInstRepository; + this.nsLcmOpOccRepository = nsLcmOpOccRepository; } public boolean addJob(final NfvoJob job) { @@ -84,9 +96,36 @@ public class DatabaseServiceProvider { return nfvoNsInstRepository.findByName(name); } - public Optional<NfvoNsInst> getNfvoNsInstByNsInstId(final String nsInstId) { - logger.info("Querying database for NfvoNsInst using nsInstId: {}", nsInstId); - return nfvoNsInstRepository.findByNsInstId(nsInstId); + public boolean saveNfvoNfInst(final NfvoNfInst nfvoNfInst) { + logger.info("Saving NfvoNfInst: {} to database", nfvoNfInst); + return nfvoNfInstRepository.save(nfvoNfInst) != null; + } + + public Optional<NfvoNfInst> getNfvoNfInstByNfInstId(final String nfInstId) { + logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId); + return nfvoNfInstRepository.findByNfInstId(nfInstId); + } + + public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) { + logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId); + return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId); } + public List<NfvoNfInst> getNfvoNfInstByNsInstIdAndNfName(final String nsInstId, final String name) { + logger.info("Querying database for NfvoNfInst using nsInstId: {} and name : {} ", nsInstId, name); + return nfvoNfInstRepository.findByNsInstNsInstIdAndName(nsInstId, name); + } + + public boolean addNSLcmOpOcc(final NsLcmOpOcc nsLcmOpOcc) { + logger.info("Adding NSLcmOpOcc: {} to database", nsLcmOpOcc); + return nsLcmOpOccRepository.save(nsLcmOpOcc) != null; + } + + public Optional<NsLcmOpOcc> getNsLcmOpOcc(final String id) { + logger.info("Querying database for NsLcmOpOcc using id: {}", id); + return nsLcmOpOccRepository.findById(id); + } + + + } |