public boolean isBaseTypeRequired(final String categoryName) {
return elementOperation.isBaseTypeRequired(categoryName);
}
+
+ /**
+ * Fetches default baseType from the template.
+ *
+ * @param categoryName the category name
+ * @return defaultBaseType mapped to the corresponding category name.
+ */
+ public String getDefaultBaseType(final String categoryName) {
+ return elementOperation.getDefaultBaseType(categoryName);
+ }
}
final Map<String, Object> baseTypesMap = new HashMap<>();
baseTypesMap.put("baseTypes", either.left().value());
baseTypesMap.put("required", elementBL.isBaseTypeRequired(categoryName));
+ baseTypesMap.put("defaultBaseType",elementBL.getDefaultBaseType(categoryName));
return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), baseTypesMap);
}
return true;
}
+ @Override
+ public String getDefaultBaseType(String categoryName) {
+ return "";
+ }
+
}
*/
boolean isBaseTypeRequired(String categoryName);
+ String getDefaultBaseType(String categoryName);
+
Either<CategoryDefinition, ActionStatus> getCategory(NodeTypeEnum nodeType, String categoryId);
Either<SubCategoryDefinition, ActionStatus> getSubCategoryUniqueForType(NodeTypeEnum nodeType, String normalizedName);
private Configuration getConfiguration() {
return ConfigurationManager.getConfigurationManager().getConfiguration();
}
+ @Override
+ public String getDefaultBaseType(final String categoryName) {
+ final Map<String, CategoryBaseTypeConfig> categoriesSpecificBaseTypeMap = getConfiguration().getServiceBaseNodeTypes();
+ if (MapUtils.isEmpty(categoriesSpecificBaseTypeMap)) {
+ return null;
+ }
+ final CategoryBaseTypeConfig categoryBaseTypeConfig = categoriesSpecificBaseTypeMap.get(categoryName);
+ if (categoryBaseTypeConfig == null) {
+ return null;
+ }
+ return categoryBaseTypeConfig.getDefaultBaseType();
+ }
@Override
public boolean isBaseTypeRequired(final String categoryName) {
interface ListBaseTypesResponse {
baseTypes: BaseTypeResponse[];
required: boolean;
+ defaultBaseType: string;
}
interface BaseTypeResponse {
this.$scope.isBaseTypeRequired = baseTypeResponseList.required;
this.$scope.baseTypes = [];
this.$scope.baseTypeVersions = [];
+ let defaultBaseType = baseTypeResponseList.defaultBaseType;
baseTypeResponseList.baseTypes.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName));
- if (this.$scope.isBaseTypeRequired) {
- const baseType = baseTypeResponseList.baseTypes[0];
- baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
- if(!this.$scope.component.derivedFromGenericType) {
- this.$scope.component.derivedFromGenericType = baseType.toscaResourceName;
+ if (this.$scope.isBaseTypeRequired || defaultBaseType != null) {
+ let baseType = baseTypeResponseList.baseTypes[0];
+ if(defaultBaseType != null){
+ baseTypeResponseList.baseTypes.forEach(baseTypeObj => {
+ if(baseTypeObj.toscaResourceName == defaultBaseType) {
+ baseType = baseTypeObj;
+ }
+ });
}
+ baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
+ this.$scope.component.derivedFromGenericType = baseType.toscaResourceName;
this.$scope.component.derivedFromGenericVersion = this.$scope.baseTypeVersions[0];
this.$scope.showBaseTypeVersions = true;
return
private boolean required;
private List<String> baseTypes;
+ private String defaultBaseType;
}