blob: f745b88d0278512f6650ed284e6e1ac54e6c5248 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
import fj.data.Either;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import javax.annotation.Resource;
import java.util.List;
public class ServiceCategoriesMigration extends JsonModelMigration<CategoryDefinition> {
@Resource(name = "element-operation")
private IElementOperation elementOperation;
@Resource(name = "element-operation-migration")
private IElementOperation elementOperationMigration;
@Override
public String description() {
return "migrate services categories";
}
@Override
Either<List<CategoryDefinition>, ?> getElementsToMigrate() {
return elementOperation.getAllCategories(NodeTypeEnum.ServiceNewCategory, false).left().map(CategoriesUtils::filterOldCategories);
}
@Override
Either<CategoryDefinition, ?> getElementFromNewGraph(CategoryDefinition node) {
return elementOperationMigration.getCategory(NodeTypeEnum.ServiceNewCategory, node.getUniqueId());
}
@Override
Either<CategoryDefinition, ActionStatus> save(CategoryDefinition graphNode) {
return elementOperationMigration.createCategory(graphNode, NodeTypeEnum.ServiceNewCategory);
}
@Override
ActionStatus getNotFoundErrorStatus() {
return ActionStatus.COMPONENT_CATEGORY_NOT_FOUND;
}
}
|