summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services/components
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/services/components
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/services/components')
-rw-r--r--catalog-ui/src/app/services/components/component-service.ts28
1 files changed, 26 insertions, 2 deletions
diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts
index bedfed5ee5..90ae850899 100644
--- a/catalog-ui/src/app/services/components/component-service.ts
+++ b/catalog-ui/src/app/services/components/component-service.ts
@@ -52,6 +52,7 @@ export interface IComponentService {
deleteComponentInstance(componentId:string, componentInstanceId:string):ng.IPromise<ComponentInstance>;
createRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
deleteRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
+ fetchRelation(componentId:string, linkId:string):ng.IPromise<RelationshipModel>;
getRequirementsCapabilities(componentId:string):ng.IPromise<any>;
updateInstanceProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>;
updateInstanceAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
@@ -513,7 +514,12 @@ export class ComponentService implements IComponentService {
public createRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer();
- this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(link)).then((response:any) => {
+ const linkPayload:RelationshipModel = new RelationshipModel(link);
+ linkPayload.relationships.forEach((rel) => {
+ delete rel.capability;
+ delete rel.requirement;
+ });
+ this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(linkPayload)).then((response:any) => {
let relation:RelationshipModel = new RelationshipModel(response.plain());
console.log("Link created successfully ", relation);
deferred.resolve(relation);
@@ -526,7 +532,12 @@ export class ComponentService implements IComponentService {
public deleteRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer();
- this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(link)).then((response:any) => {
+ const linkPayload:RelationshipModel = new RelationshipModel(link);
+ linkPayload.relationships.forEach((rel) => {
+ delete rel.capability;
+ delete rel.requirement;
+ });
+ this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(linkPayload)).then((response:any) => {
let relation:RelationshipModel = new RelationshipModel(response);
console.log("Link deleted successfully ", relation);
deferred.resolve(relation);
@@ -537,6 +548,19 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
+ public fetchRelation = (componentId:string, linkId:string):ng.IPromise<RelationshipModel> => {
+ let deferred = this.$q.defer<RelationshipModel>();
+ this.restangular.one(componentId).one("relationId").one(linkId).get().then((response:any) => {
+ let relation:RelationshipModel = new RelationshipModel(response);
+ console.log("Link fetched successfully ", relation);
+ deferred.resolve(relation);
+ }, (err)=> {
+ console.log("Failed to fetch Link Id: " + linkId);
+ deferred.reject(err);
+ });
+ return deferred.promise;
+ };
+
public getRequirementsCapabilities = (componentId:string):ng.IPromise<any> => {
let deferred = this.$q.defer();
this.restangular.one(componentId).one("requirmentsCapabilities").get().then((response:any) => {