2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
17 import _merge from 'lodash/merge';
19 import Common from '../common/Common';
22 * Rules governing what a definition can contain.
24 export default class Metamodel {
26 // ///////////////////////////////////////////////////////////////////////////////////////////////
29 * Construct from JSON definition.
30 * @param json schema definition.
33 Common.assertType(json, 'Object');
34 const dfault = require('./templates/default.metamodel.json');
35 this.json = _merge({}, dfault, json);
38 // ///////////////////////////////////////////////////////////////////////////////////////////////
41 * Get schema identifier.
45 return this.json.diagram.metadata.id;
48 // ///////////////////////////////////////////////////////////////////////////////////////////////
51 * Get lifeline constraints.
55 return this.json.diagram.lifelines.constraints;
58 // ///////////////////////////////////////////////////////////////////////////////////////////////
61 * Get lifeline metadata by lifeline ID.
62 * @param id sought lifeline.
63 * @returns lifeline if found.
66 for (const lifeline of this.json.diagram.lifelines.lifelines) {
67 if (lifeline.id === id) {
74 // ///////////////////////////////////////////////////////////////////////////////////////////////
84 // ///////////////////////////////////////////////////////////////////////////////////////////////
88 * @returns Metamodel default (permissive) Metamodel.
91 return new Metamodel({});