X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Flibraries%2Fmodel%2Fdescriptors%2FForwardingGraph.js;fp=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Flibraries%2Fmodel%2Fdescriptors%2FForwardingGraph.js;h=ef99af6f4a03172c0a5765aa034f3f16c7ca2a3d;hb=e29efc315df33d546237e270470916e26df391d6;hp=0000000000000000000000000000000000000000;hpb=9c5e457509ba5a1822c316635c6308874e61b4b9;p=osm%2FUI.git diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/ForwardingGraph.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/ForwardingGraph.js new file mode 100644 index 000000000..ef99af6f4 --- /dev/null +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/ForwardingGraph.js @@ -0,0 +1,117 @@ +/* + * + * Copyright 2016 RIFT.IO Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +/** + * Created by onvelocity on 11/23/15. + */ + +'use strict'; + +import _ from 'lodash' +import Classifier from './Classifier' +import DescriptorModel from '../DescriptorModel' +import RecordServicePath from './RecordServicePath' +import DescriptorModelFactory from '../DescriptorModelFactory' +import DescriptorModelMetaFactory from '../DescriptorModelMetaFactory' + +export default class ForwardingGraph extends DescriptorModel { + + static get type() { + return 'vnffgd'; + } + + static get className() { + return 'ForwardingGraph'; + } + + constructor(model, parent) { + super(model, parent); + this.type = 'vnffgd'; + this.uiState['qualified-type'] = 'nsd.vnffgd'; + this.className = 'ForwardingGraph'; + } + + get rsp() { + if (!this.model.rsp) { + this.model.rsp = []; + } + return this.model.rsp.map(d => DescriptorModelFactory.newRecordServicePath(d, this)); + } + + set rsp(obj) { + this.updateModelList('rsp', obj, RecordServicePath); + } + + createRsp() { + const model = DescriptorModelMetaFactory.createModelInstanceForType('nsd.vnffgd.rsp'); + return this.rsp = new RecordServicePath(model, this); + } + + removeRsp(obj) { + this.children.filter(d => d.id === obj.id).forEach(rsp => rsp.remove()); + } + + get recordServicePaths() { + return this.rsp; + } + + removeRecordServicePath(child) { + this.rsp = this.rsp.filter(rsp => rsp.uid !== child.uid); + this.removeChild(child); + } + + get classifier() { + if (!this.model['classifier']) { + this.model['classifier'] = []; + } + return this.model['classifier'].map(d => DescriptorModelFactory.newClassifier(d, this)); + } + + set classifier(obj) { + this.updateModelList('classifier', obj, Classifier); + } + + createClassifier(model) { + model = model || DescriptorModelMetaFactory.createModelInstanceForType(DescriptorModelFactory.Classifier.qualifiedType); + return this.classifier = DescriptorModelFactory.newClassifier(model, this); + } + + removeClassifier(child) { + return this.removeModelListItem('classifier', child); + } + + remove() { + if (this.parent) { + return this.parent.removeVnffgd(this); + } + } + + getColor() { + + } + + createClassifierForRecordServicePath(rsp) { + const classifier = this.createClassifier(); + classifier.model['rsp-id-ref'] = rsp.id; + } + + removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex) { + this.rsp.forEach(rsp => rsp.removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex)); + } + +} +