3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * Created by onvelocity on 11/23/15.
24 import Position
from '../../graph/Position'
25 import DescriptorModel
from '../DescriptorModel'
26 import DescriptorModelFactory
from '../DescriptorModelFactory'
27 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
28 import ClassifierConnectionPointRef
from './ClassifierConnectionPointRef'
31 * A VirtualNetworkFunctionConnectionPoint is always a child of a VNFD. We use it to build VnfdConnectionPointRef instances. So convenience
32 * methods are add to access the fields needed to do that.
34 export default class Classifier
extends DescriptorModel
{
40 static get className() {
44 static get qualifiedType() {
45 return 'nsd.vnffgd.' + Classifier
.type
;
48 constructor(model
, parent
) {
50 this.type
= Classifier
.type
;
51 this.uiState
['qualified-type'] = Classifier
.qualifiedType
;
52 this.className
= Classifier
.className
;
53 this.position
= new Position();
54 this._vnfdConnectionPointRef
= new ClassifierConnectionPointRef(this);
57 get matchAttributes() {
58 if (!this.model
['match-attributes']) {
59 this.model
['match-attributes'] = {};
61 return this.model
['match-attributes'].map(d
=> DescriptorModelFactory
.newClassifierMatchAttributes(d
, this));
64 set matchAttributes(obj
) {
65 return this.updateModelList('match-attributes', obj
, DescriptorModelFactory
.ClassifierMatchAttributes
);
68 createMatchAttributes() {
69 const model
= DescriptorModelMetaFactory
.createModelInstanceForType(DescriptorModelFactory
.ClassifierMatchAttributes
.qualifiedType
);
70 return this.matchAttributes
= DescriptorModelFactory
.newClassifierMatchAttributes(model
, this);
73 removeMatchAttributes(matchAttributes
) {
74 return this.removeModelListItem('matchAttributes', matchAttributes
);
77 get vnfdConnectionPointRef() {
78 return this._vnfdConnectionPointRef
|| {};
81 // vnfdConnectionPointRef is read only by design
83 addVnfdConnectionPoint(cp
) {
84 this.vnfdConnectionPointRef
.vnfdRef
= cp
.parent
.vnfdRef
;
85 this.vnfdConnectionPointRef
.vnfdId
= cp
.vnfdId
;
86 this.vnfdConnectionPointRef
.vnfdIndex
= cp
.vnfdIndex
;
87 this.vnfdConnectionPointRef
.vnfdConnectionPointName
= cp
.name
;
88 this.vnfdConnectionPointRef
.cpNumber
= cp
.cpNumber
;
92 return this.parent
.removeClassifier(this);