aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/graph/match-relation.ts
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-ui/src/app/models/graph/match-relation.ts
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/models/graph/match-relation.ts')
-rw-r--r--catalog-ui/src/app/models/graph/match-relation.ts68
1 files changed, 18 insertions, 50 deletions
diff --git a/catalog-ui/src/app/models/graph/match-relation.ts b/catalog-ui/src/app/models/graph/match-relation.ts
index 4fb073d579..8d139d6405 100644
--- a/catalog-ui/src/app/models/graph/match-relation.ts
+++ b/catalog-ui/src/app/models/graph/match-relation.ts
@@ -20,80 +20,49 @@
'use strict';
import {Requirement} from "../requirement";
import {Capability} from "../capability";
-import {Relationship, RelationshipModel, RelationType} from "./relationship";
+import {Relationship, RelationshipModel} from "./relationship";
+import {PropertyModel} from "../properties";
-export class MatchBase {
+export class Match {
requirement:Requirement;
+ capability:Capability;
isFromTo:boolean;
fromNode:string;
toNode:string;
+ capabilityProperties:Array<PropertyModel>; // use this to store the capability properties, since there are times the capability itself is not available (when fulfilled).
+ private _relationship:Relationship;
- constructor(requirement:Requirement, isFromTo:boolean, fromNode:string, toNode:string) {
+ constructor(requirement:Requirement, capability:Capability, isFromTo:boolean, fromNode:string, toNode:string) {
this.requirement = requirement;
+ this.capability = capability;
this.isFromTo = isFromTo;
this.fromNode = fromNode;
this.toNode = toNode;
}
- public getDisplayText = (menuSide:string):string => {
- return '';
- };
-
- public isOwner = (id:string):boolean => {
- return false;
- }
-
-}
-
-export class MatchReqToReq extends MatchBase {
-
- secondRequirement:Requirement;
-
- constructor(requirement:Requirement, secondRequirement:Requirement, isFromTo:boolean, fromNode:string, toNode:string) {
- super(requirement, isFromTo, fromNode, toNode);
- this.secondRequirement = secondRequirement;
- }
-
- public getDisplayText = (menuSide:string):string => {
- if ('left' == menuSide) {
- return this.requirement.getFullTitle();
+ // NOTE: Hold the relationship instance for cases capability / requirement are not available (when fulfilled).
+ // In case relationship instance is not manually saved to here, then build the relationship from the given capability and requirement.
+ public get relationship():Relationship {
+ if (!this._relationship) {
+ this._relationship = this.matchToRelation();
}
- return this.secondRequirement.getFullTitle();
- };
-
- public isOwner = (id:string):boolean => {
- return this.secondRequirement.ownerId === id || this.requirement.ownerId === id;
+ return this._relationship;
}
-}
-
-export class MatchReqToCapability extends MatchBase {
-
- capability:Capability;
-
- constructor(requirement:Requirement, capability:Capability, isFromTo:boolean, fromNode:string, toNode:string) {
- super(requirement, isFromTo, fromNode, toNode);
- this.capability = capability;
+ public set relationship(relationship) {
+ this._relationship = relationship;
}
public matchToRelation = ():Relationship => {
- let relationship:Relationship = new Relationship();
- relationship.capability = this.capability.name;
- relationship.capabilityOwnerId = this.capability.ownerId;
- relationship.capabilityUid = this.capability.uniqueId;
- relationship.relationship = new RelationType(this.capability.type);
- relationship.requirement = this.requirement.name;
- relationship.requirementOwnerId = this.requirement.ownerId;
- relationship.requirementUid = this.requirement.uniqueId;
+ const relationship:Relationship = new Relationship();
+ relationship.setRelationProperties(this.capability, this.requirement);
return relationship;
};
-
public getDisplayText = (menuSide:string):string => {
if (this.isFromTo && 'left' == menuSide || !this.isFromTo && 'right' == menuSide) {
return this.requirement.getFullTitle();
}
return this.capability.getFullTitle();
-
};
public isOwner = (id:string):boolean => {
@@ -108,4 +77,3 @@ export class MatchReqToCapability extends MatchBase {
};
}
-