1 | /*
|
2 | * Licensed under the Apache License, Version 2.0 (the "License");
|
3 | * you may not use this file except in compliance with the License.
|
4 | * You may obtain a copy of the License at
|
5 | *
|
6 | * http://www.apache.org/licenses/LICENSE-2.0
|
7 | *
|
8 | * Unless required by applicable law or agreed to in writing, software
|
9 | * distributed under the License is distributed on an "AS IS" BASIS,
|
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 | * See the License for the specific language governing permissions and
|
12 | * limitations under the License.
|
13 | */
|
14 |
|
15 | ;
|
16 |
|
17 | const ClassDeclaration = require('./classdeclaration');
|
18 |
|
19 | /** Class representing the definition of a Participant.
|
20 | * @extends ClassDeclaration
|
21 | * @see See {@link ClassDeclaration}
|
22 | *
|
23 | * @class
|
24 | * @memberof module:concerto-core
|
25 | */
|
26 | class ParticipantDeclaration extends ClassDeclaration {
|
27 | /**
|
28 | * Create an ParticipantDeclaration.
|
29 | * @param {ModelFile} modelFile the ModelFile for this class
|
30 | * @param {Object} ast - The AST created by the parser
|
31 | * @throws {IllegalModelException}
|
32 | */
|
33 | constructor(modelFile, ast) {
|
34 | super(modelFile, ast);
|
35 | this._isParticipantDeclaration = true;
|
36 | }
|
37 |
|
38 | /**
|
39 | * Returns true if this class can be pointed to by a relationship
|
40 | *
|
41 | * @return {boolean} true if the class may be pointed to by a relationship
|
42 | */
|
43 | isRelationshipTarget() {
|
44 | return true;
|
45 | }
|
46 |
|
47 | /**
|
48 | * Returns the base system type for Participants from the system namespace
|
49 | *
|
50 | * @return {string} the short name of the base system type
|
51 | */
|
52 | getSystemType() {
|
53 | let systemType = this.modelFile.getModelManager().getSystemModelTable().get('Participant');
|
54 | return systemType !== undefined ? systemType : null;
|
55 | }
|
56 |
|
57 | /**
|
58 | * Alternative instanceof that is reliable across different module instances
|
59 | * @see https://github.com/hyperledger/composer-concerto/issues/47
|
60 | *
|
61 | * @param {object} object - The object to test against
|
62 | * @returns {boolean} - True, if the object is an instance of a ParticipantDeclaration
|
63 | */
|
64 | static [Symbol.hasInstance](object){
|
65 | return typeof object !== 'undefined' && object !== null && Boolean(object._isParticipantDeclaration);
|
66 | }
|
67 | }
|
68 |
|
69 | module.exports = ParticipantDeclaration;
|