2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
23 import java.util.List;
25 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
26 import org.openecomp.sdc.be.model.Resource;
27 import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 import fj.data.Either;
33 public class VFResourcesMigration extends ComponentMigration<Resource> {
35 private static Logger LOGGER = LoggerFactory.getLogger(VFResourcesMigration.class);
37 @javax.annotation.Resource(name = "resource-operation")
38 private IResourceOperation resourceOperation;
40 @javax.annotation.Resource(name = "resource-version-migration")
41 private VersionMigration<Resource> versionMigration;
44 public String description() {
49 Either<List<Resource>, ?> getElementsToMigrate() {
50 return resourceOperation.getVFResources();
54 boolean save(Resource element) {
55 requirementsCapabilitiesMigrationService.overrideInstanceCapabilitiesRequirements(element);
56 return super.save(element);
60 boolean doPostSaveOperation(Resource element) {
61 return element.getComponentInstances() == null ||
62 (requirementsCapabilitiesMigrationService.associateFulfilledRequirements(element, NodeTypeEnum.Resource) &&
63 requirementsCapabilitiesMigrationService.associateFulfilledCapabilities(element, NodeTypeEnum.Resource));
67 boolean doPostMigrateOperation(List<Resource> elements) {
68 LOGGER.info("migrating VFs versions");
69 return versionMigration.buildComponentsVersionChain(elements);
73 void doPreMigrationOperation(List<Resource> elements) {
74 super.doPreMigrationOperation(elements);
75 setMissingTemplateInfo(elements);