Merge "Added Modeling concept expression"
authorDan Timoney <dtimoney@att.com>
Tue, 23 Jul 2019 18:44:36 +0000 (18:44 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 23 Jul 2019 18:44:36 +0000 (18:44 +0000)
56 files changed:
cds-ui/client/src/app/common/constants/app-constants.ts
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html [new file with mode: 0644]
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss [new file with mode: 0644]
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.spec.ts [new file with mode: 0644]
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts [new file with mode: 0644]
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.html
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts [new file with mode: 0644]
cds-ui/client/src/app/feature-modules/blueprint/select-template/select-template.module.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.service.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts
cds-ui/server/src/controllers/data-dictionary.controller.ts
cds-ui/server/src/datasources/resource-dictionary.datasource-template.ts
cds-ui/server/src/services/resource-dictionary.service.ts
components/scripts/python/ccsdk_netconf/common.py
docs/datadictionary/index.rst
docs/datadictionary/resourcedefinitioncodesnip.rst [moved from docs/datadictionary/resourceDefinitionCode.rst with 100% similarity]
docs/datadictionary/resourcesource.rst
docs/microservices/bluePrintsProcessorMS.rst
docs/microservices/controllerBlueprintStudioProcessorMS.rst
docs/microservices/images/blueprintprocessor.jpg [moved from docs/media/blueprintprocessor.jpg with 100% similarity]
docs/microservices/workflow.rst [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ScriptComponentExtensions.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
ms/blueprintsprocessor/parent/pom.xml
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompiledScript.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsConfiguration.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptingHostTest.kt [deleted file]
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/SampleBlueprintFunctionNode.kt [moved from ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts with 63% similarity]
ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts1/simple.cba.kts [deleted file]
ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts2/simple.cba.kts [deleted file]

index 283ce73..bcfcc4e 100644 (file)
@@ -96,5 +96,7 @@ export const GlobalContants = {
 export const ResourceDictionaryURLs = {
     saveResourceDictionary: '/resourcedictionary/save',
     searchResourceDictionaryByTags: '/resourcedictionary/search',
-    searchResourceDictionaryByName: ''
+    searchResourceDictionaryByName: '',
+    getSources: '/resourcedictionary/source-mapping',
+    getModelType: '/resourcedictionary/model-type'
 }
\ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html
new file mode 100644 (file)
index 0000000..11c2ff0
--- /dev/null
@@ -0,0 +1,31 @@
+<!--
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+============LICENSE_END============================================
+-->
+<form class="search-form" [formGroup]="myControl">
+    <mat-form-field class="search-full-width">
+        <input #resourceSelect type="text" [(ngModel)]="searchText" placeholder="Search Resources" matInput [matAutocomplete]="auto" formControlName="search_input">
+        <button matSuffix mat-icon-button (click)="fetchResourceByName()"><mat-icon>search</mat-icon></button>
+        <mat-autocomplete #auto="matAutocomplete">
+            <mat-option (click)="selected(option)" *ngFor="let option of options" [value]="option.tags">
+                {{option.tags}}
+            </mat-option>
+        </mat-autocomplete>
+    </mat-form-field>
+</form>
\ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss
new file mode 100644 (file)
index 0000000..93f5c9d
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+============LICENSE_END============================================
+*/
\ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.spec.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.spec.ts
new file mode 100644 (file)
index 0000000..431eea7
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+============LICENSE_END============================================
+*/
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { SearchFromDatabaseComponent } from './search-from-database.component';
+
+describe('SearchFromDatabaseComponent', () => {
+  let component: SearchFromDatabaseComponent;
+  let fixture: ComponentFixture<SearchFromDatabaseComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ SearchFromDatabaseComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(SearchFromDatabaseComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts
new file mode 100644 (file)
index 0000000..a145086
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+============LICENSE_END============================================
+*/
+
+import { Component, OnInit, ViewChild, EventEmitter, Output  } from '@angular/core';
+import { FormBuilder, FormGroup, Validators} from '@angular/forms';
+import { SearchTemplateService } from '../search-template.service';
+import { MatAutocompleteTrigger } from '@angular/material';
+import { SearchPipe } from 'src/app/common/shared/pipes/search.pipe';
+@Component({
+  selector: 'app-search-from-database',
+  templateUrl: './search-from-database.component.html',
+  styleUrls: ['./search-from-database.component.scss']
+})
+export class SearchFromDatabaseComponent implements OnInit {
+
+  myControl: FormGroup;
+  @Output() resourcesData = new EventEmitter();  
+  options: any[]   = [];
+  @ViewChild('resourceSelect', { read: MatAutocompleteTrigger }) resourceSelect: MatAutocompleteTrigger;
+
+  searchText: string = '';
+  constructor(private _formBuilder: FormBuilder,
+              private existingModelService: SearchTemplateService)  { }
+  
+ ngOnInit() {
+    this.myControl = this._formBuilder.group({
+      search_input: ['', Validators.required]
+    });
+  }
+ selected(value){
+   this.resourcesData.emit(value);
+   }
+
+   fetchResourceByName() {
+      this.existingModelService.searchByTags("/searchByTags/",this.searchText)
+      .subscribe(data=>{
+          console.log(data);
+          data.forEach(element => {
+            this.options.push(element)
+          });          
+        this.resourceSelect.openPanel();
+      }, error=>{
+        window.alert('error' + error);
+      })
+   }
+
+}
index 491c5e0..6a4a88c 100644 (file)
@@ -27,15 +27,5 @@ limitations under the License.
     </div>
 </div>
 <div *ngIf="optionSelected==2">
-    <form class="search-form" [formGroup]="myControl">
-        <mat-form-field class="search-full-width">
-            <input #resourceSelect type="text" [(ngModel)]="searchText" placeholder="Search Resources" matInput [matAutocomplete]="auto" formControlName="search_input">
-            <button matSuffix mat-icon-button (click)="fetchResourceByName()"><mat-icon>search</mat-icon></button>
-            <!-- <mat-autocomplete #auto="matAutocomplete">
-                    <mat-option (click)="selected(option)" *ngFor="let option of options | search : searchText" [value]="option.tags">
-                        {{option.tags}}
-                    </mat-option>
-                </mat-autocomplete> -->
-        </mat-form-field>
-    </form>
+    <app-search-from-database></app-search-from-database>
 </div>
\ No newline at end of file
index 64352b2..ce7d5aa 100644 (file)
@@ -34,6 +34,7 @@ import { LoaderService } from '../../../../common/core/services/loader.service';
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
 import { MatAutocompleteTrigger } from '@angular/material';
 
+
 @Component({
   selector: 'app-search-template',
   templateUrl: './search-template.component.html',
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts
new file mode 100644 (file)
index 0000000..1102966
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software 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.
+============LICENSE_END============================================
+*/
+
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { SearchFromDatabaseComponent } from './search-from-database/search-from-database.component';
+import { SearchTemplateComponent } from './search-template.component';
+import { ReactiveFormsModule } from '@angular/forms';
+import { AppMaterialModule } from 'src/app/common/modules/app-material.module';
+import { SharedModule} from 'src/app/common/shared/shared.module';
+@NgModule({
+  declarations: [
+    SearchTemplateComponent,
+    SearchFromDatabaseComponent],
+  imports: [
+    CommonModule,
+    ReactiveFormsModule,
+    AppMaterialModule,
+    SharedModule   
+  ],
+  exports:[
+    SearchTemplateComponent,
+    SearchFromDatabaseComponent
+    ]
+})
+export class SearchTemplateModule { }
index 16947d4..f66b78c 100644 (file)
@@ -27,13 +27,13 @@ import { MetadataComponent } from './metadata/metadata.component';
 import { SelectTemplateComponent } from './select-template.component';
 import { SelectTemplateRoutingModule } from './select-template-routing.module';
 import { AppMaterialModule } from 'src/app/common/modules/app-material.module';
+import { SearchTemplateModule} from './search-template/search-template.module';
 
 @NgModule({
   declarations: [
     TemplateOptionsComponent,
-    SearchTemplateComponent,
-    MetadataComponent,
-    SelectTemplateComponent
+     MetadataComponent,
+     SelectTemplateComponent
   ],
    exports: [
     TemplateOptionsComponent,
@@ -45,7 +45,8 @@ import { AppMaterialModule } from 'src/app/common/modules/app-material.module';
     CommonModule,
     SelectTemplateRoutingModule,
     ReactiveFormsModule,
-    AppMaterialModule
+    AppMaterialModule,
+    SearchTemplateModule
   ]
 })
 export class SelectTemplateModule { }
index 5be2a14..19db82c 100644 (file)
 */-->
 
 
-<button disabled style="opacity: 0.5;" (click) ="changeView()" class="toggle-view-btn">{{viewText}}</button>
+<button (click) ="changeView()" class="toggle-view-btn">{{viewText}}</button>
 <br><br>
-<div *ngIf="designerMode">
+<!-- <div *ngIf="designerMode"> -->
+<div [hidden] = "!designerMode">
    <mat-card class="metadata-card">
         <mat-card-header>
             <mat-card-title>Resource Metadata</mat-card-title>
@@ -45,7 +46,8 @@
     </mat-card>
 </div>
 
-<div *ngIf="editorMode">
+<!-- <div *ngIf="editorMode"> -->
+<div [hidden] = "!editorMode">
        <json-editor  class="jsoneditor" *ngIf="editorMode" [options]="options" [data]="resources" on-change="onChange($event)"></json-editor>
 </div>
  
index bd06abb..417f6ed 100644 (file)
@@ -36,4 +36,14 @@ export class ResourceEditService {
     saveResource(resource) {
        return this.api.post(ResourceDictionaryURLs.saveResourceDictionary, resource);
     }
+
+    getSources() {
+        // to do
+        return this.api.get('ResourceDictionaryURLs.getSources');
+    }
+
+    getModelType(name) {
+        // to do
+        return this.api.get("ResourceDictionaryURLs.getModelType + '/' + name");
+    }
 }
\ No newline at end of file
index b1474d2..b179f01 100644 (file)
       class="sources-list"
       (cdkDropListDropped)="drop($event)">
        <div class="sources-box" *ngFor="let item of sourcesOptions;let i = index" cdkDrag>
-               <mat-expansion-panel class="expansion-panel">
+          <mat-expansion-panel class="expansion-panel" (opened)="selected(item)">
                        <mat-expansion-panel-header>
                                <mat-panel-title>
-                                       {{item}}
+                  {{item.name}}
                                </mat-panel-title>
                        </mat-expansion-panel-header>
-                       <json-editor [options]="options" [data]="selected(item)" on-change="onChange(item,$event)"></json-editor>
+            <json-editor [options]="options" [data]="item.data" on-change="onChange(item,$event)"></json-editor>
                         </mat-expansion-panel>
                         <button matSuffix mat-icon-button (click)="delete(item,i)"><mat-icon class="icon">delete</mat-icon></button>
        </div>
@@ -44,7 +44,7 @@
     <h3>Source Options</h3>
        <mat-form-field>
        <input [(ngModel)]="searchText" type="input" matInput placeholder="search sources">
-       <button matSuffix mat-icon-button><mat-icon>search</mat-icon></button>
+      <button matSuffix mat-icon-button (click)="getResources()"><mat-icon>search</mat-icon></button>
        <mat-hint>db,mdsal,input,default,..</mat-hint>
        </mat-form-field>
        <br><br>
@@ -53,7 +53,7 @@
       [cdkDropListData]="option"
       class="options-list"
       (cdkDropListDropped)="drop($event)">
-      <div class="options-box" *ngFor="let item of option | search :searchText" cdkDrag>{{item}}</div>
+      <div class="options-box" *ngFor="let item of option | search :searchText" cdkDrag>{{item.name}}</div>
     </div>
    </div>
    <div> 
index 52b19f7..c4ad83d 100644 (file)
@@ -31,6 +31,7 @@ import { A11yModule } from '@angular/cdk/a11y';
 import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
 import { ISourcesData } from 'src/app/common/core/store/models/sourcesData.model';
 import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor';
+import { ResourceEditService } from '../resource-edit.service';
 
 @Component({
   selector: 'app-sources-template',
@@ -43,13 +44,13 @@ export class SourcesTemplateComponent implements OnInit {
     options = new JsonEditorOptions(); 
     rdState: Observable<IResourcesState>;
     resources: IResources;
-    option = ['mdsal','default'];
+    option = [];
     sources:ISourcesData; 
     sourcesOptions = [];
-    sourcesData = [];
+    sourcesData = {};
     @Output() resourcesData = new EventEmitter();  
  
constructor(private store: Store<IAppState>) {
   constructor(private store: Store<IAppState>, private apiService: ResourceEditService) {
     this.rdState = this.store.select('resources');
     this.options.mode = 'text';
     this.options.modes = [ 'text', 'tree', 'view'];
@@ -79,10 +80,35 @@ export class SourcesTemplateComponent implements OnInit {
      this.resources.sources = Object.assign({},originalSources);
  };
     
- selected(value){
-       this.sourcesData=this.sources[value];
-    return this.sourcesData;    
- }    
+ selected(sourceValue){
+   this.sourcesData= [];//this.sources[value];
+   this.apiService.getModelType(sourceValue.value)
+   .subscribe(data=>{
+      console.log(data);
+      data.forEach(item =>{
+        if(typeof(item)== "object") {
+           for (let key1 in item) {
+              if(key1 == 'properties') {                  
+                 let newPropOnj = {}
+                 for (let key2 in item[key1]) {
+                    console.log(item[key1][key2]);
+                    let varType = item[key1][key2].type
+                    // let property :  varType = 
+                    newPropOnj[key2] = item[key1][key2];
+                 }
+              }
+           }
+        }
+      });
+      this.sourcesData = data;
+      this.sourcesOptions.forEach(item=>{
+         if(item.name == sourceValue.name) {
+            item.data = data;
+         }
+      })       
+     return this.sourcesData;
+   })    
+}    
 
  delete(item,i){
        if(confirm("Are sure you want to delete this source ?")) {
index 486c286..63587e6 100644 (file)
@@ -84,4 +84,15 @@ export class DataDictionaryController {
   }) resourceDictionaryList: JSON): Promise<any> {
     return await this.rdservice.searchbyNames(resourceDictionaryList);
   }
+
+  @get('/resourcedictionary/model-type/{source}', {
+    responses: {
+      '200': {
+        content: { 'application/json': {} },
+      },
+    },
+  })
+  async getmodelType(@param.path.string('source') source: string) {
+    return await this.rdservice.getModelType(source);
+  }
 }
index c749eee..af96aca 100644 (file)
@@ -86,6 +86,23 @@ export default {
             "functions": {
                 "searchbyNames": ["resourceDictionaryList"]
 
+            }
+        },
+        ,
+        {
+            "template": {
+                "method": "GET",
+                "url": controllerApiConfig.http.url + "/model-type/{source}",
+                "headers": {
+                    "accepts": "application/json",
+                    "content-type": "application/json",
+                    "authorization": controllerApiConfig.http.authToken
+                },
+                "responsePath": "$.*"
+            },
+            "functions": {
+                "getModelType": ["source"]
+
             }
         }
     ]
index 8bc61fa..9a781d6 100644 (file)
@@ -7,7 +7,8 @@ export interface ResourceDictionaryService {
   getSourceMapping(): Promise<JSON>;
   getByTags(tags: string): Promise<JSON>;
   save(resourceDictionary: JSON): Promise<JSON>;
-  searchbyNames(resourceDictionaryList: JSON): Promise<JSON>;
+  searchbyNames(resourceDictionaryList: JSON): Promise<JSON>;  
+  getModelType(source: string): Promise<JSON>;
 }
 
 export class ResourceDictionaryServiceProvider implements Provider<ResourceDictionaryService> {
index f161e29..896fb91 100644 (file)
@@ -1,4 +1,5 @@
 #  Copyright (c) 2019 Bell Canada.
+#  Modifications Copyright (c) 2018 - 2019 IBM, Bell Canada.
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -18,11 +19,11 @@ class ResolutionHelper:
     self.component_function = component_function
 
   def resolve_and_generate_message_from_template_prefix(self, artifact_prefix):
-    return self.component_function.resolveAndGenerateMessage(artifact_prefix)
+    return self.component_function.contentFromResolvedArtifact(artifact_prefix)
 
   def resolve_and_generate_message(self, artifact_mapping, artifact_template):
     return self.component_function.resolveAndGenerateMessage(artifact_mapping,
                                                              artifact_template)
 
   def retrieve_resolved_template_from_database(self, key, artifact_template):
-    return self.component_function.resolveFromDatabase(key, artifact_template)
+    return self.component_function.storedContentFromResolvedArtifact(key, artifact_template)
index 0d87158..3ac8587 100644 (file)
@@ -40,7 +40,7 @@ Here is how input-key-mapping, output-key-mapping and key-dependencies can be us
 .. toctree::
    :maxdepth: 1
    
-resourceDefintionCode 
+       resourcedefinitioncodesnip 
 
 
 Resource source:
@@ -61,10 +61,10 @@ Also please click below for resource source available details
 .. _Resource: https://wiki.onap.org/display/DW/Modeling+Concepts#ModelingConcepts-NodeResourceSource
 
 
-.. |image0| image:: media/mandatory.jpg
+.. |image0| image:: media/mandatory.JPG
    :width: 7.88889in 
    :height: 4.43750in
    
-.. |image1| image:: media/optional.jpg
+.. |image1| image:: media/optional.JPG
    :width: 7.88889in 
    :height: 4.43750in
\ No newline at end of file
index 1a69fd6..852a34f 100644 (file)
@@ -11,10 +11,13 @@ Expects the value to be provided as input to the request.
 
 source-input:
 
+.. code: json
+print("
   "description": "This is Input Resource Source Node Type",
   "version": "1.0.0",
   "properties": {},
   "derived_from": "tosca.nodes.ResourceSource"
+")
 
 
 Default:
@@ -39,21 +42,21 @@ CDS is currently deployed along the side of SDNC, hence the primary database con
 
 |image0|
 
-.. |image0| image:: media/sqltable.jpg
+.. |image0| image:: media/sqltable.JPG
    :width: 7.88889in 
    :height: 4.43750in
 
 .. toctree::
    :maxdepth: 1  
 
-sourceprimarydbcode
+   sourceprimarydbcode
 
 Connection to a specific database can be expressed through the endpoint-selector property, which refers to a macro defining the information about the database the connect to. Understand TOSCA Macro in the context of CDS.
 
 .. toctree::
    :maxdepth: 1 
 
-dbsystemcode
+   dbsystemcode
 
 
 REST:
@@ -65,7 +68,7 @@ CDS is currently deployed along the side of SDNC, hence the default rest connect
 
 |image1|
 
-.. |image1| image:: media/resttable.jpg
+.. |image1| image:: media/resttable.JPG
    :width: 7.88889in 
    :height: 4.43750in
 
@@ -96,7 +99,7 @@ Expects a script to be provided.
 
 |image2|
 
-.. |image2| image:: media/capabilitytable.jpg
+.. |image2| image:: media/capabilitytable.JPG
    :width: 7.88889in 
    :height: 4.43750in
    
@@ -104,7 +107,7 @@ Expects a script to be provided.
 .. toctree::
    :maxdepth: 1   
 
-       sourcecapabilitycode
+   sourcecapabilitycode
        
 Complex Type:
 =============
@@ -122,14 +125,14 @@ As part of this request, the expected response will be as below.
 .. toctree::
    :maxdepth: 1   
 
-       complexResponse
+   complexResponse
 
 What is of interest is the address and id fields. For the process to return these two values, we need to create a custom data-type, as bellow
 
 .. toctree::
    :maxdepth: 1 
    
-       dt-netbox-ip
+   dt-netbox-ip
 
 The type of the data dictionary will be dt-netbox-ip.
 
@@ -138,4 +141,4 @@ To tell the resolution framework what is of interest in the response, the output
 .. toctree::
    :maxdepth: 1 
    
-create_netbox_ip_address
\ No newline at end of file
+   create_netbox_ip_address
\ No newline at end of file
index 911f999..3f30813 100644 (file)
@@ -14,7 +14,7 @@ Micro service to Manage Controller Blueprint Models, such as Resource Dictionary
 This microservice is used to deploy Controller Blueprint Archive file in Run time database. This also helps to test the Valid Blueprint.
 
 Architecture:
-==============
+-------------
 
 |image0|
 
@@ -23,7 +23,7 @@ Architecture:
    :width: 800px
    
 Running Blueprints Processor Microservice Locally:
-==================================================
+--------------------------------------------------
 
 The purpose of this page is to show how to run the Blueprints Processor microservice locally, using the docker-compose.yaml file provided in the project.
 
@@ -48,7 +48,7 @@ Build it using the Maven profile called Docker:
     mvn clean install -Pdocker
        
 Start Docker containers using docker-composer:
-==============================================
+----------------------------------------------
 
 Navigate to the docker-compose file in the distribution module:
 
@@ -66,7 +66,7 @@ To verify the logs generated by docker-composer, type:
        
        
 Testing the environment:
-========================
+------------------------
 
 Point your browser to http://localhost:8000/api/v1/execution-service/ping (please note that the port is 8000, not 8080)
 
index 5c67d6c..683b694 100644 (file)
@@ -10,7 +10,7 @@ The Controller Blueprint Archive is the overall service design, fully model-driv
 The CBA is .zip file which is saved in Controller Blueprint Database.
 
 Dynamic API:
-===========
+------------
 
 The nature of the API request and response is meant to be model driven and dynamic. They both share the same definition.
 
@@ -22,11 +22,18 @@ The first top level element will always be either $actionName-request for a requ
 
 Then the content within this element is fully based on the workflow input and output.
 
+.. toctree::
+   :maxdepth: 1
+   
+   dynamicapi
 
 Enrichment:
-===========
+-----------
 
 Helps to generate complete valid CBA file.
 
-  
+.. toctree::
+   :maxdepth: 1
+   
+   enrichment
    
\ No newline at end of file
diff --git a/docs/microservices/workflow.rst b/docs/microservices/workflow.rst
new file mode 100644 (file)
index 0000000..b74a49d
--- /dev/null
@@ -0,0 +1,73 @@
+.. This work is licensed under a Creative Commons Attribution 4.0
+.. International License. http://creativecommons.org/licenses/by/4.0
+.. Copyright (C) 2019 IBM.
+
+Workflow
+========
+
+A workflow defines an overall action to be taken on the service, hence is an entry-point for the run-time execution of the CBA package.
+
+A workflow also defines inputs and outputs that will defined the payload contract of the request and response (see Dynamic API)
+
+A workflow can be composed of one or multiple sub-actions to execute.
+
+A CBA package can have as many workflows as needed.
+
+Single action
+-------------
+
+The workflow is directly backed by a node_template of type tosca.nodes.Component
+
+Multiple sub-actions
+--------------------
+The workflow is backed by Directed Graph engine, node_template of type dg-generic, and are imperative workflows.
+
+A DG used as workflow for CDS is composed of multiple execute nodes; each individual execute node refers to a plugin, that is a node_template of type tosca.nodes.Component.
+
+Below the properties of a workflow:
+
+
+
+Workflow Example
+----------------
+
+.. code:: json
+
+print("
+{
+  "workflow": {
+    "resource-assignment": {                                <- workflow-name
+      "inputs": {
+        "vnf-id": {                                         <- static inputs
+          "required": true,
+          "type": "string"
+        },
+        "resource-assignment-properties": {                    <- dynamic inputs
+          "required": true,
+          "type": "dt-resource-assignment-properties"
+        }
+      },
+      "steps": {
+        "call-resource-assignment": {                       <- step-name
+          "description": "Resource Assignment Workflow",
+          "target": "resource-assignment-process"           <- node_template targeted by the step
+        }
+      },
+      "outputs": {
+        "template-properties": {                            <- output
+          "type": "json",                                   <- complex type
+          "value": {
+            "get_attribute": [                              <- uses expression to retrieve attribute from context
+              "resource-assignment",
+              "assignment-params"
+            ]
+          }
+        }
+      }
+    }
+  }
+}
+")
+
+
+TOSCA definition: http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/csd01/TOSCA-Simple-Profile-YAML-v1.2-csd01.html#_Toc494454203
\ No newline at end of file
index bac211a..510621b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2019 IBM.
+ *  Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -50,4 +51,8 @@ fun AbstractComponentFunction.netconfDeviceInfo(requirementName: String): Device
 
 private fun AbstractComponentFunction.netconfDeviceInfo(capabilityProperty: MutableMap<String, JsonNode>): DeviceInfo {
     return JacksonUtils.getInstanceFromMap(capabilityProperty, DeviceInfo::class.java)
-}
\ No newline at end of file
+}
+
+/**
+ * Blocking Methods called from Jython Scripts
+ */
\ No newline at end of file
index 0e97267..938affc 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
 
+import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.async
 import kotlinx.coroutines.awaitAll
 import kotlinx.coroutines.coroutineScope
@@ -25,10 +26,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.R
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolutionService
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -47,7 +45,7 @@ interface ResourceResolutionService {
                                     resolutionKey: String): String
 
     suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                                 artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
+                                 artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, JsonNode>
 
     suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
                                  artifactPrefix: String, properties: Map<String, Any>): String
@@ -85,17 +83,19 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
 
     override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
                                           artifactNames: List<String>,
-                                          properties: Map<String, Any>): MutableMap<String, String> {
+                                          properties: Map<String, Any>): MutableMap<String, JsonNode> {
 
 
         val resourceAssignmentRuntimeService =
             ResourceAssignmentUtils.transformToRARuntimeService(bluePrintRuntimeService, artifactNames.toString())
 
-        val resolvedParams: MutableMap<String, String> = hashMapOf()
+        val resolvedParams: MutableMap<String, JsonNode> = hashMapOf()
         artifactNames.forEach { artifactName ->
             val resolvedContent = resolveResources(resourceAssignmentRuntimeService, nodeTemplateName,
                 artifactName, properties)
-            resolvedParams[artifactName] = resolvedContent
+
+            resolvedParams[artifactName] = resolvedContent.asJsonType()
+
         }
         return resolvedParams
     }
index 3e1f071..9faf879 100755 (executable)
@@ -26,6 +26,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
 import org.onap.ccsdk.cds.controllerblueprints.db.resources.BlueprintCatalogServiceImpl
 import org.slf4j.LoggerFactory
 import org.springframework.dao.DataIntegrityViolationException
@@ -46,12 +48,17 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
     private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
 
     override suspend fun delete(name: String, version: String) {
+        // Clean blueprint script cache
+        val cacheKey = BluePrintFileUtils
+                .compileCacheKey(normalizedPathName(bluePrintPathConfiguration.blueprintDeployPath, name, version))
+        BluePrintCompileCache.cleanClassLoader(cacheKey)
+        log.info("removed cba file name($name), version($version) from cache")
         // Cleaning Deployed Blueprint
         deleteNBDir(bluePrintPathConfiguration.blueprintDeployPath, name, version)
         log.info("removed cba file name($name), version($version) from deploy location")
         // Cleaning Data Base
         blueprintModelRepository
-            .deleteByArtifactNameAndArtifactVersion(name, version)
+                .deleteByArtifactNameAndArtifactVersion(name, version)
         log.info("removed cba file name($name), version($version) from database")
     }
 
@@ -60,7 +67,7 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
 
         val deployFile = normalizedFile(bluePrintPathConfiguration.blueprintDeployPath, name, version)
         val cbaFile = normalizedFile(bluePrintPathConfiguration.blueprintArchivePath,
-            UUID.randomUUID().toString(), "cba.zip")
+                UUID.randomUUID().toString(), "cba.zip")
 
         if (extract && deployFile.exists()) {
             log.info("cba file name($name), version($version) already present(${deployFile.absolutePath})")
@@ -110,7 +117,7 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
             log.info("Overwriting blueprint model :$artifactName::$artifactVersion")
             blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion)
             val deployFile =
-                normalizedPathName(bluePrintPathConfiguration.blueprintDeployPath, artifactName, artifactVersion)
+                    normalizedPathName(bluePrintPathConfiguration.blueprintDeployPath, artifactName, artifactVersion)
             deleteNBDir(deployFile).let {
                 if (it) log.info("Deleted deployed blueprint model :$artifactName::$artifactVersion")
                 else log.info("Fail to delete deployed blueprint model :$artifactName::$artifactVersion")
index 49a2c62..a16c520 100644 (file)
@@ -76,7 +76,8 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
             }
             BluePrintConstants.SCRIPT_KOTLIN -> {
                 val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl()
-                scriptComponent = bluePrintScriptsService.scriptInstance<T>(bluePrintContext, scriptClassReference, false)
+                scriptComponent = bluePrintScriptsService.scriptInstance<T>(bluePrintContext.rootPath,
+                        bluePrintContext.name(), bluePrintContext.version(), scriptClassReference, false)
             }
             BluePrintConstants.SCRIPT_JYTHON -> {
                 scriptComponent = blueprintJythonService.jythonComponentInstance(bluePrintContext, scriptClassReference) as T
index 4d05550..b03c7b4 100755 (executable)
         <repository>
             <id>spring-libs-milestone</id>
             <name>Spring Milestone Maven Repository</name>
+            <url>http://oss.jfrog.org/artifactory/oss-release-local/</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>spring-libs-milestone-snapshot</id>
+            <name>Spring Milestone Maven Repository - snapshots</name>
             <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
         </repository>
     </repositories>
 
index cea18ef..34a2d9c 100644 (file)
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.*
 import org.apache.commons.lang3.ObjectUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
 import org.slf4j.helpers.MessageFormatter
 import kotlin.reflect.KClass
 
@@ -30,6 +31,11 @@ import kotlin.reflect.KClass
  * @author Brinda Santh
  */
 
+fun <T : Any> logger(clazz: T) = LoggerFactory.getLogger(clazz.javaClass)!!
+
+fun <T : KClass<*>> logger(clazz: T) = LoggerFactory.getLogger(clazz.java)!!
+
+
 fun <T : Any> T.bpClone(): T {
     return ObjectUtils.clone(this)
 }
@@ -253,4 +259,8 @@ fun nullToEmpty(value: String?): String {
     return if (isNotEmpty(value)) value!! else ""
 }
 
+inline fun <reified T : JsonNode> T.isComplexType(): Boolean {
+    return this is ObjectNode || this is ArrayNode
+}
+
 
index 15b3e22..d301340 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,7 +67,8 @@ data class OperationOutputExpression(
         val modelableEntityName: String = "SELF",
         val interfaceName: String,
         val operationName: String,
-        val propertyName: String
+        val propertyName: String,
+        var subPropertyName: String? = null
 )
 
 data class DSLExpression(
index 68e5b0a..a2cba95 100644 (file)
@@ -630,6 +630,8 @@ class ToscaMetaData {
     lateinit var csarVersion: String
     lateinit var createdBy: String
     lateinit var entityDefinitions: String
+    var templateName: String? = null
+    var templateVersion: String? = null
     var templateTags: String? = null
 }
 
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt
new file mode 100644 (file)
index 0000000..8267e5d
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  Copyright © 2019 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
+
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+
+interface BluePrintDefinitions {
+
+    /** Define the service Template Model */
+    fun serviceTemplate(): ServiceTemplate
+
+    /** Load Custom Definitions that may used during runtime **/
+    fun loadOtherDefinitions()
+
+    /** Utility Method to add the definition */
+    fun addOtherDefinition(key: String, definition: Any)
+
+    /** Utility method to get the definition */
+    fun <T : Any> otherDefinition(key: String): T
+
+    fun otherDefinitions(): MutableMap<String, Any>
+}
+
+abstract class AbstractBluePrintDefinitions : BluePrintDefinitions {
+
+    private val otherDefinitionMap: MutableMap<String, Any> = hashMapOf()
+
+    constructor() {
+        loadOtherDefinitions()
+    }
+
+    override fun loadOtherDefinitions() {
+    }
+
+    override fun <T : Any> otherDefinition(key: String): T {
+        return otherDefinitionMap[key] as T
+    }
+
+    override fun addOtherDefinition(key: String, definition: Any) {
+        otherDefinitionMap[key] = definition
+    }
+
+    override fun otherDefinitions(): MutableMap<String, Any> {
+        return otherDefinitionMap
+    }
+
+}
\ No newline at end of file
index 8bb0cd0..7912e78 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
 
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintSourceCode
 
 interface BluePrintScriptsService {
 
-    suspend fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String,
-                           reCompile: Boolean): T
+    suspend fun <T> scriptInstance(bluePrintSourceCode: BluePrintSourceCode, scriptClassName: String): T
+
+    suspend fun <T> scriptInstance(blueprintBasePath: String, artifactName: String, artifactVersion: String,
+                                   scriptClassName: String, reCompile: Boolean): T
+
+    suspend fun <T> scriptInstance(blueprintBasePath: String, scriptClassName: String, reCompile: Boolean): T
+
+    suspend fun <T> scriptInstance(cacheKey: String, scriptClassName: String): T
 
     suspend fun <T> scriptInstance(scriptClassName: String): T
 }
\ No newline at end of file
index 03258c2..2f131f6 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.core.scripts
 
-import java.io.File
 import java.io.Serializable
-import java.net.URL
-import java.net.URLClassLoader
 import kotlin.reflect.KClass
 import kotlin.script.experimental.api.*
 
-open class BluePrintCompiledScript<out JarFile : File>(
-        private val scriptCompilationConfiguration: ScriptCompilationConfiguration,
-        private val compiledJar: File) :
-        CompiledScript<JarFile>, Serializable {
+open class BluePrintCompiledScript<out BCS : String>(
+        val cacheKey: String,
+        val scriptCompilationConfiguration: ScriptCompilationConfiguration) :
+        CompiledScript<BCS>, Serializable {
 
     lateinit var scriptClassFQName: String
 
     override val compilationConfiguration: ScriptCompilationConfiguration
         get() = scriptCompilationConfiguration
 
-    override suspend fun getClass(scriptEvaluationConfiguration: ScriptEvaluationConfiguration?): ResultWithDiagnostics<KClass<*>> = try {
+    override suspend fun getClass(scriptEvaluationConfiguration: ScriptEvaluationConfiguration?)
+            : ResultWithDiagnostics<KClass<*>> = try {
 
-        val baseClassLoader = Thread.currentThread().contextClassLoader
-
-        val urls = arrayListOf<URL>()
-        urls.add(compiledJar.toURI().toURL())
-        val classLoaderWithDependencies = URLClassLoader(urls.toTypedArray(), baseClassLoader)
+        /** Get the class loader from the cache */
+        val classLoaderWithDependencies = BluePrintCompileCache.classLoader(cacheKey)
 
         val clazz = classLoaderWithDependencies.loadClass(scriptClassFQName).kotlin
         clazz.asSuccess()
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt
new file mode 100644 (file)
index 0000000..db139eb
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *  Copyright © 2019 IBM.
+ *
+ *  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.
+ */
+
+package org.onap.ccsdk.cds.controllerblueprints.core.scripts
+
+import com.google.common.cache.CacheBuilder
+import com.google.common.cache.CacheLoader
+import com.google.common.cache.LoadingCache
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import java.net.URL
+import java.net.URLClassLoader
+
+
+object BluePrintCompileCache {
+    val log = logger(BluePrintCompileCache::class)
+
+    private val classLoaderCache: LoadingCache<String, URLClassLoader> = CacheBuilder.newBuilder()
+            .maximumSize(10)
+            .build(BluePrintClassLoader)
+
+    fun classLoader(key: String): URLClassLoader {
+        return classLoaderCache.get(key)
+    }
+
+    fun cleanClassLoader(key: String) {
+        classLoaderCache.invalidate(key)
+        log.info("Cleaned script cache($key)")
+    }
+
+    fun hasClassLoader(key: String): Boolean {
+        return classLoaderCache.asMap().containsKey(key)
+    }
+}
+
+object BluePrintClassLoader : CacheLoader<String, URLClassLoader>() {
+
+    val log = logger(BluePrintClassLoader::class)
+
+    override fun load(key: String): URLClassLoader {
+        log.info("loading cache key($key)")
+        val keyPath = normalizedFile(key)
+        if (!keyPath.exists()) {
+            throw BluePrintException("failed to load cache($key), missing files.")
+        }
+        val urls = arrayListOf<URL>()
+        keyPath.walkTopDown()
+                .filter { it.name.endsWith("cba-kts.jar") }
+                .forEach {
+                    log.debug("Adding (${it.absolutePath}) to cache key($key)")
+                    urls.add(it.toURI().toURL())
+                }
+        return URLClassLoader(urls.toTypedArray(), this.javaClass.classLoader)
+    }
+}
\ No newline at end of file
index df33025..e231f6d 100644 (file)
@@ -30,8 +30,8 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler
 import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
 import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer
 import org.jetbrains.kotlin.config.*
+import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
 import org.slf4j.LoggerFactory
-import java.io.File
 import kotlin.script.experimental.api.*
 import kotlin.script.experimental.host.ScriptingHostConfiguration
 import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
@@ -60,7 +60,11 @@ open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostC
 
             val compiledJarFile = blueprintSourceCode.targetJarFile
 
-            if (!compiledJarFile.exists() || blueprintSourceCode.regenerate) {
+            /** Check cache is present for the blueprint scripts */
+            val hasCompiledCache = BluePrintCompileCache.hasClassLoader(blueprintSourceCode.cacheKey)
+
+            if (!compiledJarFile.exists() || blueprintSourceCode.regenerate || !hasCompiledCache) {
+                log.info("compiling for cache key(${blueprintSourceCode.cacheKey})")
 
                 var environment: KotlinCoreEnvironment? = null
 
@@ -68,6 +72,11 @@ open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostC
 
                 try {
 
+                    // Clean the cache, if present
+                    if (hasCompiledCache) {
+                        BluePrintCompileCache.cleanClassLoader(blueprintSourceCode.cacheKey)
+                    }
+
                     val compilerConfiguration = CompilerConfiguration().apply {
 
                         put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector)
@@ -83,6 +92,8 @@ open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostC
 
                         // Add all Kotlin Sources
                         addKotlinSourceRoots(blueprintSourceCode.blueprintKotlinSources)
+                        // for Kotlin 1.3.30 greater
+                        //add(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS, ScriptingCompilerConfigurationComponentRegistrar())
 
                         languageVersionSettings = LanguageVersionSettingsImpl(
                                 LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, mapOf(AnalysisFlags.skipMetadataVersionCheck to true)
@@ -108,9 +119,11 @@ open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostC
                 }
             }
 
-            val res = BluePrintCompiledScript<File>(scriptCompilationConfiguration, compiledJarFile)
+            checkFileExists(compiledJarFile) { "couldn't generate compiled jar(${compiledJarFile.absolutePath})" }
+
+            val compiledScript = BluePrintCompiledScript<String>(blueprintSourceCode.cacheKey, scriptCompilationConfiguration)
 
-            return ResultWithDiagnostics.Success(res, messageCollector.diagnostics)
+            return compiledScript.asSuccess()
 
         } catch (ex: Throwable) {
             return failure(ex.asDiagnostics())
index 4fcc33d..05a1471 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.slf4j.LoggerFactory
 import java.util.*
+import kotlin.reflect.full.createInstance
 import kotlin.script.experimental.api.*
 import kotlin.script.experimental.host.BasicScriptingHost
 import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
@@ -30,19 +31,16 @@ val blueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfigura
 
 open class BlueprintScriptingHost(evaluator: ScriptEvaluator) : BasicScriptingHost(blueprintScriptCompiler, evaluator) {
 
-    override fun eval(
-            script: SourceCode,
-            scriptCompilationConfiguration: ScriptCompilationConfiguration,
-            configuration: ScriptEvaluationConfiguration?
-    ): ResultWithDiagnostics<EvaluationResult> =
+    override fun eval(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration,
+                      configuration: ScriptEvaluationConfiguration?): ResultWithDiagnostics<EvaluationResult> =
 
             runInCoroutineContext {
 
-                compiler(script, scriptCompilationConfiguration)
+                blueprintScriptCompiler(script, scriptCompilationConfiguration)
                         .onSuccess {
                             evaluator(it, configuration)
                         }.onFailure { failedResult ->
-                            val messages = failedResult.reports?.joinToString("\n")
+                            val messages = failedResult.reports.joinToString("\n")
                             throw BluePrintProcessorException(messages)
                         }
             }
@@ -52,21 +50,21 @@ open class BluePrintScriptEvaluator(private val scriptClassName: String) : Scrip
 
     private val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!!
 
-    override suspend operator fun invoke(
-            compiledScript: CompiledScript<*>,
-            scriptEvaluationConfiguration: ScriptEvaluationConfiguration?
+    override suspend operator fun invoke(compiledScript: CompiledScript<*>,
+                                         scriptEvaluationConfiguration: ScriptEvaluationConfiguration?
     ): ResultWithDiagnostics<EvaluationResult> =
             try {
                 log.debug("Getting script class name($scriptClassName) from the compiled sources ")
+
                 val bluePrintCompiledScript = compiledScript as BluePrintCompiledScript
                 bluePrintCompiledScript.scriptClassFQName = scriptClassName
 
-                val res = compiledScript.getClass(scriptEvaluationConfiguration)
-                when (res) {
-                    is ResultWithDiagnostics.Failure -> res
+                val classResult = compiledScript.getClass(scriptEvaluationConfiguration)
+                when (classResult) {
+                    is ResultWithDiagnostics.Failure -> classResult
                     is ResultWithDiagnostics.Success -> {
 
-                        val scriptClass = res.value
+                        val scriptClass = classResult.value
                         val args = ArrayList<Any?>()
                         scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach {
                             args.add(it.value)
@@ -78,10 +76,14 @@ open class BluePrintScriptEvaluator(private val scriptClassName: String) : Scrip
                             args.addAll(it)
                         }
 
-                        val instance = scriptClass.java.constructors.single().newInstance(*args.toArray())
-                                ?: throw BluePrintProcessorException("failed to create instance from the script")
+                        val instance = if (args.isNotEmpty()) {
+                            scriptClass.java.constructors.single().newInstance(*args.toArray())
+                                    ?: throw BluePrintProcessorException("failed to create instance from the script")
+                        } else {
+                            scriptClass.createInstance()
+                        }
 
-                        log.info("Created script instance of type ${instance.javaClass}")
+                        log.debug("Created script instance of type ${instance.javaClass}")
 
                         ResultWithDiagnostics.Success(EvaluationResult(ResultValue.Value(scriptClass.qualifiedName!!,
                                 instance, "", instance),
index 3ac7901..e019237 100644 (file)
@@ -35,7 +35,7 @@ object BluePrintScripCompilationConfiguration : ScriptCompilationConfiguration(
                 //classpathFromClassloader(BluePrintScripCompilationConfiguration::class.java.classLoader)
                 classpathFromClasspathProperty()
             }
-            ide{
+            ide {
                 acceptedLocations(ScriptAcceptedLocation.Everywhere)
             }
 
@@ -46,6 +46,7 @@ open class BluePrintSourceCode : SourceCode {
     lateinit var blueprintKotlinSources: MutableList<String>
     lateinit var moduleName: String
     lateinit var targetJarFile: File
+    lateinit var cacheKey: String
     var regenerate: Boolean = false
 
     override val text: String
index e2c0260..3600353 100644 (file)
@@ -19,42 +19,59 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts
 
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
-import java.io.File
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
 import java.util.*
 import kotlin.script.experimental.api.ResultValue
 import kotlin.script.experimental.api.resultOrNull
 import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
 
+
 open class BluePrintScriptsServiceImpl : BluePrintScriptsService {
 
-    override suspend fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String,
-                                            reCompile: Boolean): T {
+    val log = logger(BluePrintScriptsServiceImpl::class)
 
-        val kotlinScriptPath = blueprintContext.rootPath.plus(File.separator)
-                .plus(BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR)
+    override suspend fun <T> scriptInstance(bluePrintSourceCode: BluePrintSourceCode, scriptClassName: String): T {
+        val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<BluePrintKotlinScript>()
+        val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName)
 
-        val compiledJar = kotlinScriptPath.plus(File.separator)
-                .plus(bluePrintScriptsJarName(blueprintContext))
+        val compiledResponse = BlueprintScriptingHost(scriptEvaluator)
+                .eval(bluePrintSourceCode, compilationConfiguration, null)
 
-        val scriptSource = BluePrintSourceCode()
+        val returnValue = compiledResponse.resultOrNull()?.returnValue as? ResultValue.Value
+        return returnValue?.value!! as T
+    }
+
+    override suspend fun <T> scriptInstance(blueprintBasePath: String, artifactName: String, artifactVersion: String,
+                                            scriptClassName: String, reCompile: Boolean): T {
 
         val sources: MutableList<String> = arrayListOf()
-        sources.add(kotlinScriptPath)
+        sources.add(normalizedPathName(blueprintBasePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR))
+
+        val scriptSource = BluePrintSourceCode()
         scriptSource.blueprintKotlinSources = sources
-        scriptSource.moduleName = "${blueprintContext.name()}-${blueprintContext.version()}-cba-kts"
-        scriptSource.targetJarFile = File(compiledJar)
+        scriptSource.moduleName = "$artifactName-$artifactVersion-cba-kts"
+        scriptSource.cacheKey = BluePrintFileUtils.compileCacheKey(blueprintBasePath)
+        scriptSource.targetJarFile = BluePrintFileUtils.compileJarFile(blueprintBasePath, artifactName, artifactVersion)
         scriptSource.regenerate = reCompile
+        return scriptInstance(scriptSource, scriptClassName)
+    }
 
-        val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<BluePrintKotlinScript>()
-        val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName)
-
-        val compiledResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource, compilationConfiguration,
-                null)
-
-        val returnValue = compiledResponse.resultOrNull()?.returnValue as? ResultValue.Value
+    override suspend fun <T> scriptInstance(blueprintBasePath: String, scriptClassName: String,
+                                            reCompile: Boolean): T {
+        val toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintBasePath)
+        checkNotNull(toscaMetaData.templateName) { "couldn't find 'Template-Name' key in TOSCA.meta" }
+        checkNotNull(toscaMetaData.templateVersion) { "couldn't find 'Template-Version' key in TOSCA.meta" }
+        return scriptInstance(blueprintBasePath, toscaMetaData.templateName!!, toscaMetaData.templateVersion!!,
+                scriptClassName, reCompile)
+    }
 
-        return returnValue?.value!! as T
+    override suspend fun <T> scriptInstance(cacheKey: String, scriptClassName: String): T {
+        val args = ArrayList<Any?>()
+        return BluePrintCompileCache.classLoader(cacheKey).loadClass(scriptClassName).constructors
+                .single().newInstance(*args.toArray()) as T
     }
 
     override suspend fun <T> scriptInstance(scriptClassName: String): T {
@@ -62,8 +79,4 @@ open class BluePrintScriptsServiceImpl : BluePrintScriptsService {
         return Thread.currentThread().contextClassLoader.loadClass(scriptClassName).constructors
                 .single().newInstance(*args.toArray()) as T
     }
-
-    private fun bluePrintScriptsJarName(blueprintContext: BluePrintContext): String {
-        return "${blueprintContext.name()}-${blueprintContext.version()}-cba-kts.jar"
-    }
 }
\ No newline at end of file
index 26181bb..066516f 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.data.*
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
 
 /**
  *
@@ -32,7 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
  */
 class BluePrintContext(val serviceTemplate: ServiceTemplate) {
 
-    private val log= LoggerFactory.getLogger(this::class.toString())
+    private val log = LoggerFactory.getLogger(this::class.toString())
 
     /**
      * Blueprint CBA extracted file location
@@ -43,6 +43,13 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
      */
     var entryDefinition = ""
 
+    /** Other definitions along with model, It may Resource Definition, Resource Assignments, Configurations etc..*/
+    var otherDefinitions: MutableMap<String, Any> = hashMapOf()
+
+    fun <T> otherDefinition(key: String) = otherDefinitions[key] as T
+
+    fun checkOtherDefinition(key: String) = otherDefinitions.containsKey(key)
+
     fun imports(): List<ImportDefinition>? = serviceTemplate.imports
 
     fun dslDefinitions() = serviceTemplate.dslDefinitions
index 32cb6ac..fbf9116 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -170,10 +170,16 @@ object BluePrintExpressionService {
             throw BluePrintException(String.format("missing operation output expression, " +
                     "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode))
         }
+
+        var subPropertyName: String? = null
+        if (arrayNode.size() == 5)
+            subPropertyName = arrayNode[4].asText()
+
         return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(),
                 interfaceName = arrayNode[1].asText(),
                 operationName = arrayNode[2].asText(),
-                propertyName = arrayNode[3].asText()
+                propertyName = arrayNode[3].asText(),
+                subPropertyName = subPropertyName
         )
     }
 
index e6f3f71..ba210df 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018-2019 IBM.
+ * Modifications Copyright © 2018-2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -213,8 +213,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 
     override fun loadEnvironments(type: String, fileName: String) {
         BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value ->
-            setNodeTemplateAttributeValue(type, key.toString(), value.toString()
-                    .asJsonPrimitive())
+            setNodeTemplateAttributeValue(type, key.toString(), value.asJsonType())
         }
     }
 
index 931d31e..30bd75f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,11 +21,8 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service
 import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.data.*
-import org.onap.ccsdk.cds.controllerblueprints.core.format
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JsonParserUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils
@@ -143,8 +140,8 @@ If Property Assignment is Expression.
 
         }
         if (subAttributeName != null) {
-            if (valueNode.isObject || valueNode.isArray)
-                valueNode = JsonParserUtils.parse(valueNode, subAttributeName)
+            if (valueNode.isComplexType())
+                valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subAttributeName)
         }
         return valueNode
     }
@@ -176,8 +173,8 @@ If Property Assignment is Expression.
         valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)
 
         if (subPropertyName != null) {
-            if (valueNode.isObject || valueNode.isArray)
-                valueNode = JsonParserUtils.parse(valueNode, subPropertyName)
+            if (valueNode.isComplexType())
+                valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subPropertyName)
         }
         return valueNode
     }
@@ -190,9 +187,17 @@ If Property Assignment is Expression.
         if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) {
             outputNodeTemplateName = operationOutputExpression.modelableEntityName
         }
-        return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
+
+        var valueNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
                 operationOutputExpression.interfaceName, operationOutputExpression.operationName,
                 operationOutputExpression.propertyName)
+
+        val subPropertyName: String? = operationOutputExpression.subPropertyName
+        if (subPropertyName != null) {
+            if (valueNode.isComplexType())
+                valueNode = JsonParserUtils.parse(valueNode.asJsonString(), subPropertyName)
+        }
+        return valueNode
     }
 
     /*
index 5f9725f..17a7fd3 100755 (executable)
@@ -1,6 +1,7 @@
 /*
  * Copyright © 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright © 2019 Bell Canada.
+ * Modifications Copyright © 2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +18,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import org.slf4j.LoggerFactory
 import kotlinx.coroutines.runBlocking
 import org.apache.commons.io.FileUtils
 import org.apache.commons.lang3.StringUtils
@@ -26,7 +26,10 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ImportDefinition
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.slf4j.LoggerFactory
 import java.io.File
 import java.io.FileFilter
 import java.nio.file.Files
@@ -38,7 +41,7 @@ import java.nio.file.StandardOpenOption
 class BluePrintFileUtils {
     companion object {
 
-        private val log= LoggerFactory.getLogger(this::class.toString())
+        private val log = LoggerFactory.getLogger(this::class.toString())
 
         fun createEmptyBluePrint(basePath: String) {
 
@@ -213,11 +216,13 @@ class BluePrintFileUtils {
                     "\nCSAR-Version: <VERSION>" +
                     "\nCreated-By: <AUTHOR NAME>" +
                     "\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
+                    "\nTemplate-Name: <BLUEPRINT_NAME>"+
+                    "\nTemplate-Tags: <BLUEPRINT_VERSION>"+
                     "\nTemplate-Tags: <TAGS>"
         }
 
-       
-        fun getBluePrintFile(fileName: String, targetPath: Path) : File {
+
+        fun getBluePrintFile(fileName: String, targetPath: Path): File {
             val filePath = targetPath.resolve(fileName).toString()
             val file = File(filePath)
             check(file.exists()) {
@@ -241,6 +246,24 @@ class BluePrintFileUtils {
             return fileStorageLocation
         }
 
+        fun compileCacheKey(basePath: String): String {
+            return normalizedPathName(basePath)
+        }
+
+        private fun compileJarFileName(artifactName: String, artifactVersion: String): String {
+            return "$artifactName-$artifactVersion-cba-kts.jar"
+        }
+
+        fun compileJarFilePathName(basePath: String, artifactName: String, artifactVersion: String): String {
+            return normalizedPathName(basePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR,
+                    compileJarFileName(artifactName, artifactVersion))
+        }
+
+        fun compileJarFile(basePath: String, artifactName: String, artifactVersion: String): File {
+            return normalizedFile(compileJarFilePathName(basePath,
+                    artifactName, artifactVersion))
+        }
+
         fun stripFileExtension(fileName: String): String {
             val dotIndexe = fileName.lastIndexOf('.')
 
index ef5cb81..3a1edcc 100644 (file)
@@ -22,6 +22,8 @@ import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintImportService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
@@ -83,6 +85,8 @@ class BluePrintMetadataUtils {
                             "CSAR-Version" -> toscaMetaData.csarVersion = value
                             "Created-By" -> toscaMetaData.createdBy = value
                             "Entry-Definitions" -> toscaMetaData.entityDefinitions = value
+                            "Template-Name" -> toscaMetaData.templateName = value
+                            "Template-Version" -> toscaMetaData.templateVersion = value
                             "Template-Tags" -> toscaMetaData.templateTags = value
                         }
                     }
@@ -133,7 +137,12 @@ class BluePrintMetadataUtils {
 
             log.info("Reading blueprint path($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
 
-            readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+            // If the EntryDefinition is Kotlin file, compile and get Service Template
+            if (toscaMetaData.entityDefinitions.endsWith("kt")) {
+                readBlueprintKotlinFile(toscaMetaData, blueprintBasePath)
+            } else {
+                readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+            }
         }
 
         private suspend fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext {
@@ -153,15 +162,42 @@ class BluePrintMetadataUtils {
         }
 
         private suspend fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {
-            val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions)
+            val normalizedBasePath = normalizedPathName(basePath)
+            val rootFilePath = normalizedPathName(normalizedBasePath, entityDefinitions)
             val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
             // Recursively Import Template files
-            val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath)
+            val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, normalizedBasePath)
             val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate()
             val blueprintContext = BluePrintContext(completeServiceTemplate)
-            blueprintContext.rootPath = basePath
+            blueprintContext.rootPath = normalizedBasePath
             blueprintContext.entryDefinition = entityDefinitions
             return blueprintContext
         }
+
+        /** Reade the Service Template Definitions from the Kotlin file */
+        private suspend fun readBlueprintKotlinFile(toscaMetaData: ToscaMetaData, basePath: String): BluePrintContext {
+
+            checkNotNull(toscaMetaData.templateName) { "couldn't find 'Template-Name' key in TOSCA.meta" }
+            checkNotNull(toscaMetaData.templateVersion) { "couldn't find 'Template-Version' key in TOSCA.meta" }
+
+            val definitionClassName = toscaMetaData.entityDefinitions.removeSuffix(".kt")
+            val normalizedBasePath = normalizedPathName(basePath)
+
+            val bluePrintScriptsService = BluePrintScriptsServiceImpl()
+            val bluePrintDefinitions = bluePrintScriptsService
+                    .scriptInstance<BluePrintDefinitions>(normalizedBasePath, toscaMetaData.templateName!!,
+                            toscaMetaData.templateVersion!!, definitionClassName, true)
+            // Get the Service Template
+            val serviceTemplate = bluePrintDefinitions.serviceTemplate()
+
+            // Clean the Default type import Definitions
+            BluePrintFileUtils.cleanImportTypes(serviceTemplate)
+
+            val blueprintContext = BluePrintContext(serviceTemplate)
+            blueprintContext.rootPath = normalizedBasePath
+            blueprintContext.entryDefinition = toscaMetaData.entityDefinitions
+            blueprintContext.otherDefinitions = bluePrintDefinitions.otherDefinitions()
+            return blueprintContext
+        }
     }
 }
\ No newline at end of file
index 342ff76..e5eef5a 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2018 IBM.
+ *  Modifications Copyright © 2018 - 2019 IBM, Bell Canada.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -38,7 +39,7 @@ class JsonParserUtils {
         }
 
         fun paths(jsonNode: JsonNode, expression: String): List<String> {
-            return paths(jsonNode.toString(), expression)
+            return paths(jsonNode, expression)
         }
 
         fun parse(jsonContent: String, expression: String): JsonNode {
@@ -54,7 +55,8 @@ class JsonParserUtils {
         }
 
         fun parseNSet(jsonNode: JsonNode, expression: String, valueNode: JsonNode): JsonNode {
-            return parseNSet(jsonNode.toString(), expression, valueNode)
+
+            return parseNSet(jsonNode, expression, valueNode)
         }
     }
 }
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImplTest.kt
new file mode 100644 (file)
index 0000000..66fec75
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.cds.controllerblueprints.core.scripts
+
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import kotlin.script.experimental.jvm.util.classpathFromClass
+import kotlin.script.experimental.jvm.util.classpathFromClassloader
+import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
+import kotlin.test.assertNotNull
+
+class BluePrintScriptsServiceImplTest {
+
+    private fun viewClassPathInfo() {
+
+        println(" *********** classpathFromClass  *********** ")
+        classpathFromClass(BluePrintScriptsServiceImplTest::class.java.classLoader,
+                BluePrintScriptsServiceImplTest::class)!!
+                .forEach(::println)
+
+        println(" *********** classpathFromClassloader  *********** ")
+        classpathFromClassloader(BluePrintScriptsServiceImplTest::class.java.classLoader)!!
+                .forEach(::println)
+
+        println(" *********** classpathFromClasspathProperty  *********** ")
+        classpathFromClasspathProperty()!!
+                .forEach(::println)
+    }
+
+    @Test
+    fun testCachedService() {
+        runBlocking {
+
+            val bluePrintScriptsService = BluePrintScriptsServiceImpl()
+
+            val basePath = normalizedPathName("src/test/resources/compile")
+            /** Load the Definitions */
+            val bluePrintDefinitions = bluePrintScriptsService
+                    .scriptInstance<BluePrintDefinitions>(basePath,
+                            "cba.scripts.ActivateBlueprintDefinitions", true)
+            assertNotNull(bluePrintDefinitions, "failed to get blueprint definitions")
+
+            val serviceTemplate = bluePrintDefinitions.serviceTemplate()
+            assertNotNull(serviceTemplate, "failed to get service template")
+
+            val customDataType = bluePrintDefinitions.otherDefinition<DataType>("datatype-custom-datatype")
+            assertNotNull(customDataType, "failed to get custom definitions")
+
+            val instance = bluePrintScriptsService
+                    .scriptInstance<BlueprintFunctionNode<String, String>>(basePath,
+                            "cba.scripts.SampleBlueprintFunctionNode", false)
+            assertNotNull(instance, "failed to get compiled instance")
+
+            val cachedInstance = bluePrintScriptsService
+                    .scriptInstance<BlueprintFunctionNode<String, String>>(basePath,
+                            "cba.scripts.SampleBlueprintFunctionNode", false)
+            assertNotNull(cachedInstance, "failed to get cached compile instance")
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptingHostTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptingHostTest.kt
deleted file mode 100644 (file)
index 2288d62..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.core.scripts
-
-
-import org.apache.commons.io.FileUtils
-import org.junit.Test
-import java.io.File
-import kotlin.script.experimental.jvm.util.classpathFromClass
-import kotlin.script.experimental.jvm.util.classpathFromClassloader
-import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
-import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
-
-class BlueprintScriptingHostTest {
-
-    private fun viewClassPathInfo() {
-
-        println(" *********** classpathFromClass  *********** ")
-        classpathFromClass(BlueprintScriptingHostTest::class.java.classLoader,
-                BlueprintScriptingHostTest::class)!!
-                .forEach(::println)
-
-        println(" *********** classpathFromClassloader  *********** ")
-        classpathFromClassloader(BlueprintScriptingHostTest::class.java.classLoader)!!
-                .forEach(::println)
-
-        println(" *********** classpathFromClasspathProperty  *********** ")
-        classpathFromClasspathProperty()!!
-                .forEach(::println)
-    }
-
-    @Test
-    fun `test same script two folders`() {
-
-        FileUtils.forceMkdir(File("target/scripts1/"))
-        FileUtils.forceMkdir(File("target/scripts2/"))
-
-        val scriptSource1 = BluePrintSourceCode()
-        scriptSource1.moduleName = "blueprint-test-script"
-
-        scriptSource1.targetJarFile = File("target/scripts1/blueprint-script-generated.jar")
-        val sources1: MutableList<String> = arrayListOf()
-        sources1.add("src/test/resources/scripts1")
-        scriptSource1.blueprintKotlinSources = sources1
-
-        val scriptClassName = "Simple_cba\$SampleComponentFunction"
-
-        val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<BluePrintKotlinScript>()
-
-        val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName)
-
-        val scriptSource2 = BluePrintSourceCode()
-        scriptSource2.moduleName = "blueprint-test-script"
-
-        scriptSource2.targetJarFile = File("target/scripts2/blueprint-script-generated.jar")
-        val sources2: MutableList<String> = arrayListOf()
-        sources2.add("src/test/resources/scripts2")
-        scriptSource2.blueprintKotlinSources = sources2
-
-        for (i in 1..2) {
-            val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource1, compilationConfiguration,
-                    null)
-        }
-
-        for (i in 1..2) {
-            val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource2, compilationConfiguration,
-                    null)
-        }
-    }
-}
\ No newline at end of file
index 1a6ccfa..6c0c30e 100644 (file)
@@ -21,9 +21,12 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils
 import kotlinx.coroutines.runBlocking
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache
 import kotlin.test.assertEquals
 import kotlin.test.assertNotNull
 import kotlin.test.assertNull
+import kotlin.test.assertTrue
 
 class BluePrintMetadataUtilsTest {
 
@@ -44,6 +47,24 @@ class BluePrintMetadataUtilsTest {
 
     }
 
+    @Test
+    fun testKotlinBluePrintContext() {
+        val path = normalizedPathName("src/test/resources/compile")
+        val blueprintContext = BluePrintMetadataUtils.getBluePrintContext(path)
+        assertNotNull(blueprintContext, "failed to get blueprint context")
+        assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
+        assertNotNull(blueprintContext.serviceTemplate, "failed to get blueprint context service template")
+        assertNotNull(blueprintContext.otherDefinitions, "failed to get blueprint contextother definitions")
+
+        var cachePresent = BluePrintCompileCache.hasClassLoader(path)
+        assertTrue(cachePresent, "failed to generate cache key ($path)")
+
+        /** Cleaning Cache */
+        BluePrintCompileCache.cleanClassLoader(path)
+        cachePresent = BluePrintCompileCache.hasClassLoader(path)
+        assertTrue(!cachePresent, "failed to remove cache key ($path)")
+    }
+
     @Test
     fun environmentDataTest() {
         val environmentPath = "./src/test/resources/environments"
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/Scripts/kotlin/ActivateBlueprintDefinitions.kt
new file mode 100644 (file)
index 0000000..4f4d210
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  Copyright © 2019 IBM.
+ *
+ *  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.
+ */
+
+package cba.scripts
+
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.dataType
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.AbstractBluePrintDefinitions
+
+class ActivateBlueprintDefinitions : AbstractBluePrintDefinitions() {
+
+    override fun serviceTemplate(): ServiceTemplate {
+
+        return serviceTemplate("sample-blue-print", "1.0.0",
+                "brindasanth@onap.com", "sample, blueprints") {
+            topologyTemplate {
+                workflowNodeTemplate("activate", "component-resource-resolution", "") {
+                    operation("ResourceResolutionExecutor", "") {
+                        inputs {
+                            property("string-value", "sample")
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    override fun loadOtherDefinitions() {
+        /** Sample Definitions */
+        val customDataType = dataType("custom-datatype", "1.0.0",
+                BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, "") {
+            property("name", BluePrintConstants.DATA_TYPE_STRING, true, "")
+            property("value", BluePrintConstants.DATA_TYPE_STRING, true, "")
+        }
+        /** Loading to definitions */
+        addOtherDefinition("datatype-custom-datatype", customDataType)
+    }
+}
\ No newline at end of file
  * limitations under the License.
  */
 
+package cba.scripts
+
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
 
-open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String>{
+open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String> {
 
     override fun getName(): String {
         return "Kotlin-Script-Function-Node"
@@ -41,4 +43,24 @@ open class SampleBlueprintFunctionNode : BlueprintFunctionNode<String, String>{
     override fun apply(t: String): String {
         return "$t-status"
     }
+
+    override suspend fun prepareRequestNB(executionRequest: String): String {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override suspend fun processNB(executionRequest: String) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: String) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override suspend fun prepareResponseNB(): String {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override suspend fun applyNB(t: String): String {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
 }
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/compile/TOSCA-Metadata/TOSCA.meta
new file mode 100644 (file)
index 0000000..b1ffabd
--- /dev/null
@@ -0,0 +1,7 @@
+TOSCA-Meta-File-Version: 1.0.0
+CSAR-Version: 1.0
+Created-By: Brinda Santh <brindasanth@in.ibm.com>
+Entry-Definitions: cba.scripts.ActivateBlueprintDefinitions.kt
+Template-Tags: Brinda Santh, activation-blueprint
+Template-Name: activate-blueprint
+Template-Version: 1.0.0
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts1/simple.cba.kts b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts1/simple.cba.kts
deleted file mode 100644 (file)
index 4fffda0..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 IBM.
- *
- * 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.
- */
-
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
-import org.springframework.stereotype.Service
-
-@Service
-open class SampleComponentFunction : BlueprintFunctionNode<String, String> {
-
-    override fun getName(): String {
-        println("Printing Name....." + "sample".asJsonPrimitive())
-        return "my Name"
-    }
-
-    override suspend fun prepareRequestNB(executionRequest: String): String {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun processNB(executionRequest: String) {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: String) {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun prepareResponseNB(): String {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun applyNB(t: String): String {
-        return "Script 1 response - $t"
-    }
-}
-
-val blueprintFunction = SampleComponentFunction()
-
-val serviceTemplate = ServiceTemplate()
-
-println("Simple script printing....")
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts2/simple.cba.kts b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts2/simple.cba.kts
deleted file mode 100644 (file)
index 4ba56c4..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 IBM.
- *
- * 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.
- */
-
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
-import org.springframework.stereotype.Service
-
-@Service
-open class SampleComponentFunction : BlueprintFunctionNode<String, String> {
-
-    override fun getName(): String {
-        println("Printing Name....." + "sample".asJsonPrimitive())
-        return "my Name"
-    }
-
-    override suspend fun prepareRequestNB(executionRequest: String): String {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun processNB(executionRequest: String) {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: String) {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun prepareResponseNB(): String {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override suspend fun applyNB(t: String): String {
-       return "Script 2 response - $t"
-    }
-}
-
-val blueprintFunction = SampleComponentFunction()
-
-val serviceTemplate = ServiceTemplate()
-
-println("Simple script printing....")