summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/componentsInstances/fullComponentInstance.ts
blob: f2c1a0a75d5ac64784b6dd34a05c0a259a98cb58 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import {
    ArtifactGroupModel,
    AttributeModel,
    CapabilitiesGroup,
    Component,
    ComponentInstance,
    IMainCategory,
    RequirementsGroup,
    Resource,
    Service
} from "app/models";
import {ComponentType} from '../../utils/constants';
import * as _ from 'lodash';


export class FullComponentInstance extends ComponentInstance {
    public contactId: string;
    public componentType: string;
    public interfaces: any;
    public tags: Array<string>;
    public version: string;
    public allVersions: any;
    public highestVersion: boolean;
    public categories: Array<IMainCategory>;
    public creationDate: number;
    public creatorFullName: string;
    public vendorName: string;
    public vendorRelease: string;
    public systemName: string;
    public uuid: string;
    public lifecycleState: string;
    public isArchived: boolean;

    public isServiceInstance: boolean;
    public isResourceInstance: boolean;
    public directives: string[];

    //service
    public serviceApiArtifacts: ArtifactGroupModel;
    public serviceType: string;
    public serviceRole: string;

    //resource
    public csarUUID: string;
    public isCsarComponent: boolean;
    public csarVersion: string;
    public csarPackageType: string;
    public packageId: string;
    public resourceType: string;
    public resourceVendorModelNumber: string;
    public capabilities: CapabilitiesGroup;
    public requirements: RequirementsGroup;

    public attributes: Array<AttributeModel>;

    constructor(componentInstance: ComponentInstance, originComponent: Component) {
        super(componentInstance);

        this.componentType = originComponent.componentType;
        this.interfaces = originComponent.interfaces;
        this.tags = [];
        this.tags = _.clone(originComponent.tags);
        this.version = originComponent.version;
        this.allVersions = originComponent.allVersions;
        this.highestVersion = originComponent.highestVersion;
        this.categories = originComponent.categories;
        this.creationDate = originComponent.creationDate;
        this.creatorFullName = originComponent.creatorFullName;
        this.vendorName = originComponent.vendorName;
        this.vendorRelease = originComponent.vendorRelease;
        this.contactId = originComponent.contactId;
        this.description = originComponent.description;
        this.systemName = originComponent.systemName;
        this.uuid = originComponent.uuid;
        this.lifecycleState = originComponent.lifecycleState;
        this.isArchived = originComponent.isArchived;
        this.attributes = originComponent.attributes;
        this.directives = componentInstance.directives;

        this.capabilities = new CapabilitiesGroup(originComponent.capabilities);
        this.requirements = new RequirementsGroup(originComponent.requirements);

        if (originComponent.componentType === ComponentType.SERVICE || originComponent.componentType
            === ComponentType.SERVICE_PROXY || originComponent.componentType === ComponentType.SERVICE_SUBSTITUTION) {
            this.isServiceInstance = true;
            this.serviceApiArtifacts = (<Service>originComponent).serviceApiArtifacts;
            this.serviceType = (<Service>originComponent).serviceType;
            this.serviceRole = (<Service>originComponent).serviceRole;
        }
        if (originComponent.componentType === ComponentType.RESOURCE) {
            this.isResourceInstance = true;
            this.csarUUID = (<Resource>originComponent).csarUUID;
            this.isCsarComponent = !!this.csarUUID;
            this.resourceType = (<Resource>originComponent).resourceType;
            this.resourceVendorModelNumber = (<Resource>originComponent).resourceVendorModelNumber;
        }
    }

    public isResource = (): boolean => {
        return this.isResourceInstance;
    }

    public isService = (): boolean => {
        return this.isServiceInstance;
    }

}