diff options
author | BT2983 <BT2983@att.com> | 2018-07-22 17:36:55 -0600 |
---|---|---|
committer | BT2983 <BT2983@att.com> | 2018-07-22 17:41:07 -0600 |
commit | 325c4c6db39da2e07d011d030c5135ecc18b6fa0 (patch) | |
tree | becc3cc3321688a40d439f67921bcf690b5c13a9 /ms/neng/src/main | |
parent | 2ea106c80d7c301413f281a96cc2f5736f9b747e (diff) |
Adding naming micro-service code - persistence.
Entities and repository classes.
Change-Id: I9d7e11fd7196c20cf74ff302f552c1732e0c9121
Issue-ID: CCSDK-342
Signed-off-by: BT2983 <BT2983@att.com>
Diffstat (limited to 'ms/neng/src/main')
11 files changed, 994 insertions, 0 deletions
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImpl.java new file mode 100644 index 00000000..76cf8c7a --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImpl.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.core.policy; + +import org.onap.ccsdk.apps.ms.neng.persistence.repository.IdentifierMapRespository; +import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Specifies parameters that control the nature of policy data and the behavior of this micro-service. + * + * <p/>This implementation gets these parameters from DB. + */ +@Component +public class PolicyParametersImpl implements PolicyParameters { + @Autowired + IdentifierMapRespository identifierMapRepository; + + @Autowired + ServiceParameterRepository serviceParameterRepository; + + static final String RECIPE_SEPERATOR_PARAM = "recipe_separator"; + static final String MAX_GEN_ATTEMPT_PARAM = "max_gen_attempt"; + + /** + * Gives the separator between the entries within the same recipe -- such as the pipe('|') character. + */ + @Override + public String getRecipeSeparator() throws Exception { + return serviceParameterRepository.findByName(RECIPE_SEPERATOR_PARAM).getValue(); + } + + /** + * Maps a given function, used in the policy, to the equivalent function in this micro-service. + */ + @Override + public String mapFunction(String name) throws Exception { + return identifierMapRepository.findByPolicyFnName(name).getJsFnName(); + } + + /** + * Maximum number of times the micro-service should attempt name generation in the same transaction + * (if all previous attempts in the same transaction fail). + */ + @Override + public int getMaxGenAttempt() throws Exception { + return Integer.parseInt(serviceParameterRepository.findByName(MAX_GEN_ATTEMPT_PARAM).getValue()); + } +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java new file mode 100644 index 00000000..7a729af7 --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java @@ -0,0 +1,145 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.io.Serializable; +import java.sql.Timestamp; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Entity representing the parameters and configuration of an external system/sub-system/application interface + * from this micro-service. + */ +@Entity +@Table(name = "EXTERNAL_INTERFACE") +public class ExternalInterface implements Serializable { + + private static final long serialVersionUID = 1L; + + Integer externalInteraceId; + String system; + String param; + String urlSuffix; + Timestamp createdTime; + String createdBy; + Timestamp lastUpdatedTime; + String lastUpdatedBy; + + /** + * Primary key for this entity. + */ + @Id + @Column(name = "EXTERNAL_INTERFACE_ID") + public Integer getExternalInteraceId() { + return externalInteraceId; + } + + public void setExternalInteraceId(Integer externalInteraceId) { + this.externalInteraceId = externalInteraceId; + } + + /** + * Name of the interfacing system. + */ + @Column(name = "SYSTEM") + public String getSystem() { + return system; + } + + public void setSystem(String system) { + this.system = system; + } + + /** + * A parameter related to the interfacing system. + */ + @Column(name = "PARAM") + public String getParam() { + return param; + } + + public void setParam(String param) { + this.param = param; + } + + /** + * URL suffix for the interfacing system. + */ + @Column(name = "URL_SUFFIX") + public String getUrlSuffix() { + return urlSuffix; + } + + public void setUrlSuffix(String urlSuffix) { + this.urlSuffix = urlSuffix; + } + + /** + * Time-stamp for this entity creation. + */ + @Column(name = "CREATED_TIME") + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } + + /** + * Identifier for the entity creation. + */ + @Column(name = "CREATED_BY") + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Time-stamp for this entity update. + */ + @Column(name = "LAST_UPDATED_TIME") + public Timestamp getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(Timestamp lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + /** + * Identifier for this entity update. + */ + @Column(name = "LAST_UPDATED_BY") + public String getLastUpdatedBy() { + return lastUpdatedBy; + } + + public void setLastUpdatedBy(String lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java new file mode 100644 index 00000000..b5a7463e --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java @@ -0,0 +1,211 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.io.Serializable; +import java.sql.Timestamp; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Represents a generated name. + */ +@Entity +@Table(name = "GENERATED_NAME") +public class GeneratedName implements Serializable { + private static final long serialVersionUID = 1L; + + Integer generatedNameId; + String externalId; + Long sequenceNumber; + String sequenceNumberEnc; + String elementType; + String name; + String prefix; + String suffix; + String isReleased; + Timestamp createdTime; + String createdBy; + Timestamp lastUpdatedTime; + String lastUpdatedBy; + + /** + * Primary key for this entity. + */ + @Id + @Column(name = "GENERATED_NAME_ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + public Integer getGeneratedNameId() { + return generatedNameId; + } + + public void setGeneratedNameId(Integer generatedNameId) { + this.generatedNameId = generatedNameId; + } + + /** + * Sequence number used for generation of this entity, as an integer. + */ + @Column(name = "SEQUNCE_NUMBER") + public Long getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(Long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + /** + * Sequence number used for generation of this entity, in the form encoded in the name. + */ + @Column(name = "SEQUENCE_NUMBER_ENC") + public String getSequenceNumberEnc() { + return sequenceNumberEnc; + } + + public void setSequenceNumberEnc(String sequenceNumberEnc) { + this.sequenceNumberEnc = sequenceNumberEnc; + } + + /** + * Type of the element. + */ + @Column(name = "ELEMENT_TYPE") + public String getElementType() { + return elementType; + } + + public void setElementType(String elementType) { + this.elementType = elementType; + } + + /** + * The generated name. + */ + @Column(name = "NAME") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Prefix of the name. + */ + @Column(name = "PREFIX") + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + /** + * Suffix of the name. + */ + @Column(name = "SUFFIX") + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + /** + * Indicator telling if the name is released from active use. + */ + @Column(name = "IS_RELEASED") + public String getIsReleased() { + return isReleased; + } + + public void setIsReleased(String isReleased) { + this.isReleased = isReleased; + } + + /** + * Time-stamp for this entity creation. + */ + @Column(name = "CREATED_TIME", insertable = false) + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } + + /** + * Identifier for the entity creation. + */ + @Column(name = "CREATED_BY") + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Time-stamp for this entity update. + */ + @Column(name = "LAST_UPDATED_TIME") + public Timestamp getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(Timestamp lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + /** + * Identifier for this entity update. + */ + @Column(name = "LAST_UPDATED_BY") + public String getLastUpdatedBy() { + return lastUpdatedBy; + } + + public void setLastUpdatedBy(String lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } + + /** + * External system ID mapped to this entity/name. + */ + @Column(name = "EXTERNAL_ID") + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java new file mode 100644 index 00000000..de8bef18 --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.io.Serializable; +import java.sql.Timestamp; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Maps identifiers (such as function names) in the policy to internal names used by this + * micro-service. + */ +@Entity +@Table(name = "IDENTIFIER_MAP") +public class IdentifierMap implements Serializable { + + private static final long serialVersionUID = 1L; + + Integer identifierMapId; + String policyFnName; + String jsFnName; + Timestamp createdTime; + String createdBy; + Timestamp lastUpdatedTime; + String lastUpdatedBy; + + /** + * Primary key for this entity. + */ + @Id + @Column(name = "IDENTIFIER_MAP_ID") + public Integer getIdentifierMapId() { + return identifierMapId; + } + + public void setIdentifierMapId(Integer identifierMapId) { + this.identifierMapId = identifierMapId; + } + + /** + * Name in the policy. + */ + @Column(name = "POLICY_FN_NAME") + public String getPolicyFnName() { + return policyFnName; + } + + public void setPolicyFnName(String policyFnName) { + this.policyFnName = policyFnName; + } + + /** + * Name in this micro-service. + */ + @Column(name = "JS_FN_NAME") + public String getJsFnName() { + return jsFnName; + } + + public void setJsFnName(String jsFnName) { + this.jsFnName = jsFnName; + } + + /** + * Time-stamp for this entity creation. + */ + @Column(name = "CREATED_TIME") + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } + + /** + * Identifier for the entity creation. + */ + @Column(name = "CREATED_BY") + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Time-stamp for this entity update. + */ + @Column(name = "LAST_UPDATED_TIME") + public Timestamp getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(Timestamp lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + /** + * Identifier for this entity update. + */ + @Column(name = "LAST_UPDATED_BY") + public String getLastUpdatedBy() { + return lastUpdatedBy; + } + + public void setLastUpdatedBy(String lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java new file mode 100644 index 00000000..01410739 --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.io.Serializable; +import java.sql.Timestamp; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Represents an entity representing policies stored in this micro-service (temporarily). + */ +@Entity +@Table(name = "POLICY_MAN_SIM") +public class PolicyDetails implements Serializable { + + private static final long serialVersionUID = 1L; + Integer policyId; + String policyName; + String policyResponse; + Timestamp createdTime; + + /** + * Primary key for this entity. + */ + @Id + @Column(name = "POLICY_ID") + @GeneratedValue(strategy = GenerationType.IDENTITY) + public Integer getPolicyId() { + return policyId; + } + + public void setPolicyId(Integer policyId) { + this.policyId = policyId; + } + + /** + * Name of the policy. + */ + @Column(name = "POLICY_NAME") + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + /** + * The text form of the policy. + */ + @Column(name = "POLICY_RESPONSE") + public String getPolicyResponse() { + return policyResponse; + } + + public void setPolicyResponse(String policyResponse) { + this.policyResponse = policyResponse; + } + + /** + * Time-stamp for this entity creation. + */ + @Column(name = "CREATED_TIME") + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java new file mode 100644 index 00000000..92cfa4ff --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.entity; + +import java.io.Serializable; +import java.sql.Timestamp; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * General parameters controlling this micro-service. + */ +@Entity +@Table(name = "SERVICE_PARAMETER") +public class ServiceParameter implements Serializable { + + private static final long serialVersionUID = 1L; + + Integer serviceParameterId; + String name; + String value; + Timestamp createdTime; + String createdBy; + Timestamp lastUpdatedTime; + String lastUpdatedBy; + + /** + * Primary key for this entity. + */ + @Id + @Column(name = "SERVICE_PARAMETER_ID") + public Integer getServiceParameterId() { + return serviceParameterId; + } + + public void setServiceParameterId(Integer serviceParameterId) { + this.serviceParameterId = serviceParameterId; + } + + /** + * The name of the parameter. + */ + @Column(name = "NAME") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * The value of the parameter. + */ + @Column(name = "VALUE") + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + /** + * Time-stamp for this entity creation. + */ + @Column(name = "CREATED_TIME") + public Timestamp getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(Timestamp createdTime) { + this.createdTime = createdTime; + } + + /** + * Identifier for the entity creation. + */ + @Column(name = "CREATED_BY") + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Time-stamp for this entity update. + */ + @Column(name = "LAST_UPDATED_TIME") + public Timestamp getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(Timestamp lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + /** + * Identifier for this entity update. + */ + @Column(name = "LAST_UPDATED_BY") + public String getLastUpdatedBy() { + return lastUpdatedBy; + } + + public void setLastUpdatedBy(String lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/ExternalInterfaceRespository.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/ExternalInterfaceRespository.java new file mode 100644 index 00000000..ab804082 --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/ExternalInterfaceRespository.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.repository; + +import org.onap.ccsdk.apps.ms.neng.persistence.entity.ExternalInterface; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +/** + * Repository for the ExternalInterface entity. + */ +public interface ExternalInterfaceRespository extends CrudRepository<ExternalInterface, Integer> { + + /** + * Gives the URL to be used for calling an external interface, for the given type of parameter. + */ + @Query("select ie.urlSuffix from ExternalInterface ie where ie.param = :param") + public String getUriByNameType(@Param("param") String param) throws Exception; +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/GeneratedNameRespository.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/GeneratedNameRespository.java new file mode 100644 index 00000000..4f5f65d5 --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/GeneratedNameRespository.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.repository; + +import java.util.List; +import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +/** + * Repository for the GeneratedName entity. + */ +public interface GeneratedNameRespository extends CrudRepository<GeneratedName, Integer> { + + /* + * Finds an entity by element type, name and the 'isReleased' flag. + */ + public GeneratedName findByElementTypeAndNameAndIsReleased(String elementType, String name, String isReleased); + + /* + * Finds entities for a given external system ID. + */ + public List<GeneratedName> findByExternalId(String externalId); + + /* + * Finds the maximum sequence number used for a given prefix and suffix. + */ + @Query("select max(sequenceNumber) from GeneratedName where prefix=:prefix " + + "and ((suffix is null and :suffix is null) or suffix=:suffix)") + public String findMaxByPrefixAndSuffix(@Param("prefix") String prefix, @Param("suffix") String suffix); + + /* + * Finds the maximum sequence number used that is greater than the given sequence number, + * for a given prefix and suffix. + */ + @Query("select max(sequenceNumber) from GeneratedName g where g.sequenceNumber > :seqNum " + + "and g.prefix=:prefix and ((:suffix is null and g.suffix is null) or g.suffix=:suffix) " + + "and g.isReleased='Y'") + public Long findNextReleasedSeq(@Param("seqNum") Long seqNum, @Param("prefix") String prefix, + @Param("suffix") String suffix); + + /* + * Finds the entity for given type and name, that is NOT already released. + */ + @Query("select g from GeneratedName g where g.elementType=:elementType " + + "and g.name=:name and (g.isReleased is null or g.isReleased ='N')") + public GeneratedName findUnReleased(@Param("elementType") String elementType, @Param("name") String name); +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/IdentifierMapRespository.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/IdentifierMapRespository.java new file mode 100644 index 00000000..f91ae5ca --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/IdentifierMapRespository.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.repository; + +import org.onap.ccsdk.apps.ms.neng.persistence.entity.IdentifierMap; +import org.springframework.data.repository.CrudRepository; + +/** + * Repository for the IdentifierMap entity. + */ +public interface IdentifierMapRespository extends CrudRepository<IdentifierMap, Integer> { + + /** + * Finds the entity by a given policy function/identifier name. + */ + public IdentifierMap findByPolicyFnName(String policyFnName); +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/PolicyDetailsRepository.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/PolicyDetailsRepository.java new file mode 100644 index 00000000..27e272e8 --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/PolicyDetailsRepository.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.repository; + +import org.onap.ccsdk.apps.ms.neng.persistence.entity.PolicyDetails; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +/** + * Repository for the PolicyDetails entity. + */ +public interface PolicyDetailsRepository extends CrudRepository<PolicyDetails, Integer> { + + /** + * Finds the entity by a given policy name. + */ + @Query("select p from PolicyDetails p where p.policyName=:policyName") + public PolicyDetails findPolicyResponseByName(@Param("policyName") String policyName); +} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/ServiceParameterRepository.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/ServiceParameterRepository.java new file mode 100644 index 00000000..36c7a94a --- /dev/null +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/repository/ServiceParameterRepository.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.persistence.repository; + +import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter; +import org.springframework.data.repository.CrudRepository; + +/** + * Repository for the ServiceParameter entity. + */ +public interface ServiceParameterRepository extends CrudRepository<ServiceParameter, Integer> { + + /** + * Finds the entity by a given name. + */ + public ServiceParameter findByName(String name); +} |