2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.apps.ms.neng.core.persistence;
23 import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName;
24 import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.stereotype.Component;
29 * Manages the persistence of generated names using a DB.
32 public class NamePersister {
34 GeneratedNameRespository repository;
37 * Persist the given name.
39 public void persist(GeneratedName name) throws Exception {
40 repository.save(name);
44 * Finds a name stored in the DB of the given type, name, and the 'isReleased' flag.
46 * @param elementType The type of the name
48 * @param isReleased An Y/N flag indicating if the name is released or not
50 public GeneratedName findByElementTypeAndNameAndReleased(String elementType, String name, String isReleased) {
51 return repository.findByElementTypeAndNameAndIsReleased(elementType, name, isReleased);
55 * Finds a name stored in the DB of the given external ID and type.
57 * @param externalId The external ID
58 * @param elementType The type of the name
60 public GeneratedName findByExternalIdAndElementType(String externalId, String elementType) {
61 return repository.findByExternalIdAndRelaxedElementType(externalId, elementType);