import org.onap.so.db.catalog.beans.ToscaCsar;
import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfRecipe;
import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
public class CatalogDbAdapterRest {
protected static Logger logger = LoggerFactory.getLogger(CatalogDbAdapterRest.class);
private static final boolean IS_ARRAY = true;
+ private static final String NETWORK_SERVICE = "network service";
@Autowired
private VnfCustomizationRepository vnfCustomizationRepo;
if (rmUuid != null && !"".equals(rmUuid)) {
logger.debug("Query recipe by resource model uuid: {}", rmUuid);
//check vnf and network and ar, the resource could be any resource.
+ Recipe recipe = null;
+
VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid);
- Recipe recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction(vnf.getModelName(), action);
+ if (vnf != null) {
+ recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr(vnf.getModelName(), action, vnf.getModelVersion());
+
+ // for network service fetch the default recipe
+ if (recipe == null && vnf.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) {
+ recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction("NS_DEFAULT", action);
+ }
+ }
+
+
if (null == recipe) {
NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
- recipe = networkRecipeRepo.findFirstByModelNameAndAction(nResource.getModelName(), action);
+ recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, vnf.getModelVersion());
+
+ // for network fetch the default recipe
+ if (recipe == null) {
+ recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action);
+ }
}
+
if (null == recipe) {
AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid);
- recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action);
+ recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion());
}
if (recipe != null) {
QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
@Column(name = "RECIPE_TIMEOUT")
private Integer recipeTimeout;
+ @Column(name = "VERSION_STR")
+ private String versionStr;
+
@BusinessKey
@Column(name = "SERVICE_TYPE")
private String serviceType;
sb.append(",networkParamXSD=" + paramXsd);
return sb.toString();
}
+
+ public String getVersionStr() {
+ return versionStr;
+ }
+
+ public void setVersionStr(String versionStr) {
+ this.versionStr = versionStr;
+ }
}
@Column(name = "RECIPE_TIMEOUT")
private Integer recipeTimeout;
+ @Column(name = "VERSION_STR")
+ private String versionStr;
+
@BusinessKey
@Column(name = "SERVICE_TYPE")
private String serviceType;
public Date getCreated() {
return created;
}
+
+ public String getVersionStr() {
+ return versionStr;
+ }
+
+ public void setVersionStr(String versionStr) {
+ this.versionStr = versionStr;
+ }
}
* 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.
VnfRecipe findVnfRecipeByServiceTypeAndAction(String serviceType, String action);
VnfRecipe findFirstVnfRecipeByNfRoleAndAction(String nfRole, String action);
+
+ VnfRecipe findFirstVnfRecipeByNfRoleAndActionAndVersionStr(String nfRole, String action, String versionStr);
}
\ No newline at end of file