2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.translator.services.heattotosca.impl.nameextractor;
19 import org.openecomp.sdc.heat.datatypes.model.Resource;
20 import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
21 import org.openecomp.sdc.translator.datatypes.heattotosca.PropertyRegexMatcher;
22 import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
23 import org.openecomp.sdc.translator.services.heattotosca.NameExtractorUtil;
24 import org.openecomp.sdc.translator.services.heattotosca.helper.ContrailTranslationHelper;
26 import java.util.List;
27 import java.util.Optional;
29 import static org.openecomp.sdc.tosca.services.ToscaConstants.HEAT_NODE_TYPE_SUFFIX;
31 public class NameExtractorContrailComputeImpl implements NameExtractor {
34 public String extractNodeTypeName(Resource resource, String resourceId, String translatedId) {
35 ContrailTranslationHelper contrailTranslationHelper = new ContrailTranslationHelper();
36 List<PropertyRegexMatcher> propertyRegexMatchers =
37 contrailTranslationHelper.getPropertyRegexMatchersForComputeNodeType();
38 Optional<String> extractedNodeTypeName = NameExtractorUtil.extractNodeTypeNameByPropertiesPriority(resource
39 .getProperties(), propertyRegexMatchers);
41 return ToscaNodeType.VFC_NODE_TYPE_PREFIX + HEAT_NODE_TYPE_SUFFIX
42 + (extractedNodeTypeName.orElseGet(() -> "compute_" + translatedId));