Added presentation of owner of EiJob 98/5198/1
authorPatrikBuhr <patrik.buhr@est.tech>
Mon, 30 Nov 2020 13:27:24 +0000 (14:27 +0100)
committerPatrikBuhr <patrik.buhr@est.tech>
Mon, 30 Nov 2020 13:32:38 +0000 (14:32 +0100)
Change-Id: I70ed2af455af7a5fa82f19c47b6cae7d18530da1
Issue-ID: NONRTRIC-294
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/JobInfo.java
webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java
webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiJob.java [deleted file]
webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiJobs.java
webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java
webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.html
webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts
webapp-frontend/src/app/interfaces/ei.jobs.ts

index e8ec292..78bbd87 100644 (file)
@@ -54,4 +54,9 @@ public class JobInfo {
     @JsonProperty("target_uri")
     public String targetUri;
 
+    @ApiModelProperty(value = "The owner of the job")
+    @SerializedName("owner")
+    @JsonProperty("owner")
+    public String owner;
+
 }
index 4243c34..c4acad2 100644 (file)
@@ -91,6 +91,7 @@ class RestApiTest {
             .typeId("type1") //
             .jobData(getStringFromFile("job-1.json")) //
             .targetUri("http://example.com/") //
+            .owner("owner") //
             .build();
         assertThat(jobs).hasSize(1) //
             .contains(gson.toJsonTree(wantedJobInfo));
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiJob.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiJob.java
deleted file mode 100644 (file)
index 56d3fc8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 Nordix Foundation
- * Modifications Copyright (C) 2020 Nordix Foundation
- * %%
- * 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.
- * ========================LICENSE_END===================================
- */
-package org.oransc.portal.nonrtric.controlpanel.mock;
-
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-
-@Value.Immutable
-@Gson.TypeAdapters
-public interface EiJob {
-
-    public String ei_job_identity();
-
-    public String target_uri();
-
-    public Object ei_job_data();
-
-    public String ei_type_identity();
-
-    public String owner();
-
-    public String status();
-
-}
index 0a486ec..ce831d3 100644 (file)
@@ -22,7 +22,9 @@ package org.oransc.portal.nonrtric.controlpanel.mock;
 
 import java.util.ArrayList;
 
-public class EiJobs extends ArrayList<EiJob> {
+import org.oransc.portal.nonrtric.controlpanel.model.JobInfo;
+
+public class EiJobs extends ArrayList<JobInfo> {
 
     private static final long serialVersionUID = -928428052502491021L;
 
index 43be49f..c0fb4f1 100644 (file)
@@ -33,10 +33,10 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.stream.Collectors;
 
 import org.oransc.portal.nonrtric.controlpanel.eiproducerapi.EiProducerApi;
+import org.oransc.portal.nonrtric.controlpanel.model.JobInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.test.context.TestConfiguration;
@@ -88,8 +88,8 @@ public class EnrichmentControllerMockConfiguration {
         @Override
         public ResponseEntity<String> getEiJobsForOneEiProducer(String eiProducerId) {
             EiJobs result = new EiJobs();
-            List<EiJob> inst = database.getEiJobsForOneEiProducer(Optional.of(eiProducerId));
-            result.addAll(inst);
+
+            result.addAll(database.getAllEiJobs());
             return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
         }
 
@@ -122,7 +122,7 @@ public class EnrichmentControllerMockConfiguration {
 
             // Create EiJob instance
             schema = getStringFromFile("job-1.json");
-            putEiJobInstance("type1", "job1", schema, "prod-1", "http://example.com/");
+            putEiJobInstance("type1", "job1", schema, "owner", "http://example.com/");
         }
 
         private String getStringFromFile(String path) {
@@ -141,13 +141,12 @@ public class EnrichmentControllerMockConfiguration {
         }
 
         void putEiJobInstance(String typeId, String instanceId, Object instanceData, String owner, String targetUrl) {
-            EiJob i = ImmutableEiJob.builder() //
-                .ei_job_data(instanceData) //
-                .ei_job_identity(instanceId) //
+            JobInfo i = JobInfo.builder() //
+                .jobData(instanceData) //
+                .id(instanceId) //
                 .owner(owner) //
-                .ei_type_identity(typeId) //
-                .target_uri(targetUrl) //
-                .status("ENABLED") //
+                .typeId(typeId) //
+                .targetUri(targetUrl) //
                 .build(); //
             eiJobs.put(instanceId, i);
         }
@@ -196,26 +195,12 @@ public class EnrichmentControllerMockConfiguration {
             return eiProducers.values();
         }
 
-        public Collection<EiJob> getAllEiJobs() {
-            return eiJobs.values();
-        }
-
-        public List<EiJob> getEiJobsForOneEiProducer(Optional<String> eiProducerId) {
-            List<EiJob> result = new ArrayList<>();
-            for (EiJob i : eiJobs.values()) {
-                if (eiProducerId.isPresent()) {
-                    if (i.owner().equals(eiProducerId.get())) {
-                        result.add(i);
-                    }
+        public List<JobInfo> getAllEiJobs() {
+            return new ArrayList<>(eiJobs.values());
 
-                } else {
-                    result.add(i);
-                }
-            }
-            return result;
         }
 
         private Map<String, EiProducer> eiProducers = new HashMap<>();
-        private Map<String, EiJob> eiJobs = new HashMap<>();
+        private Map<String, JobInfo> eiJobs = new HashMap<>();
     }
 }
index ada0384..e90f945 100644 (file)
@@ -63,10 +63,14 @@ limitations under the License.
         <th mat-header-cell *matHeaderCellDef> Type ID </th>
         <td mat-cell *matCellDef="let eiJob"> {{this.getEITypeId(eiJob)}} </td>
     </ng-container>
+    <ng-container matColumnDef="owner">
+        <th mat-header-cell *matHeaderCellDef> Owner </th>
+        <td mat-cell *matCellDef="let eiJob"> {{eiJob.owner}} </td>
+    </ng-container>
     <ng-container matColumnDef="targetUri">
         <th mat-header-cell *matHeaderCellDef> Target URI </th>
         <td mat-cell *matCellDef="let eiJob"> {{this.getTargetUri(eiJob)}} </td>
     </ng-container>
-    <tr mat-header-row *matHeaderRowDef="['id', 'typeId', 'targetUri']"></tr>
-    <tr mat-row *matRowDef="let row; columns: ['id', 'typeId', 'targetUri'];"></tr>
+    <tr mat-header-row *matHeaderRowDef="['id', 'typeId', 'owner', 'targetUri']"></tr>
+    <tr mat-row *matRowDef="let row; columns: ['id', 'typeId', 'owner', 'targetUri'];"></tr>
 </table>
\ No newline at end of file
index 3360577..15c4738 100644 (file)
@@ -97,14 +97,14 @@ export class EICoordinatorComponent implements OnInit {
     }
 
     getEITypeId(eiJob: EIJob): string {
-        if (eiJob.ei_type_identity){
+        if (eiJob.ei_type_identity) {
             return eiJob.ei_type_identity;
         }
         return '< No type >';
     }
 
     getTargetUri(eiJob: EIJob): string {
-        if (eiJob.target_uri){
+        if (eiJob.target_uri) {
             return eiJob.target_uri;
         }
         return '< No target URI >';
@@ -119,21 +119,21 @@ export class EICoordinatorComponent implements OnInit {
     }
 
     getEIProducerId(eiProducer: EIProducer): string {
-        if (eiProducer.ei_producer_id){
+        if (eiProducer.ei_producer_id) {
             return eiProducer.ei_producer_id;
         }
         return '< No id>';
     }
 
     getEIProducerTypes(eiProducer: EIProducer): string[] {
-        if (eiProducer.ei_producer_types){
+        if (eiProducer.ei_producer_types) {
             return eiProducer.ei_producer_types;
         }
         return ['< No types >'];
     }
 
     getEIProducerStatus(eiProducer: EIProducer): string {
-        if (eiProducer.status){
+        if (eiProducer.status) {
             return eiProducer.status;
         }
         return '< No status >';
index e7d034a..4ead13f 100644 (file)
 // Models of data used by the EI Coordinator
 
 export interface EIJobBis {
-    eiTypeId: string;
-    jobResultUri: string;
-    jobOwner: string;
-    jobStatusNotificationUri: string;
-    jobDefinition: any;
-  }
+  eiTypeId: string;
+  jobResultUri: string;
+  jobOwner: string;
+  jobStatusNotificationUri: string;
+  jobDefinition: any;
+}
 
-  export interface EIJob {
-    ei_job_identity: string;
-    ei_job_data: any;
-    ei_type_identity: string;
-    target_uri: string;
-  }
+export interface EIJob {
+  ei_job_identity: string;
+  ei_job_data: any;
+  ei_type_identity: string;
+  target_uri: string;
+  owner: string;
+}
 
-  export interface EIType {
-    id: string;
-    description: string;
-  }
+export interface EIType {
+  id: string;
+  description: string;
+}
 
-  export interface EIProducer {
-    ei_producer_id: string;
-    ei_producer_types: string[];
-    status: string;
-  }
\ No newline at end of file
+export interface EIProducer {
+  ei_producer_id: string;
+  ei_producer_types: string[];
+  status: string;
+}
\ No newline at end of file