Merge branch 'recursive-orch'
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / workflow / tasks / Resource.java
index 447f899..3617512 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
  * 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
 
 package org.onap.so.bpmn.infrastructure.workflow.tasks;
 
-public class Resource {
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+
+public class Resource implements Serializable {
 
+    private static final long serialVersionUID = 4259534487473481127L;
     private String resourceId;
     private WorkflowType resourceType;
     private boolean generated;
@@ -30,11 +38,28 @@ public class Resource {
     private String vnfCustomizationId;
     private String vfModuleCustomizationId;
     private String cvnfModuleCustomizationId;
-
-    public Resource(WorkflowType resourceType, String resourceId, boolean generated) {
+    private String instanceName;
+    private String modelInvariantId;
+    private String modelVersionId;
+    private String modelCustomizationId;
+    private int processingPriority;
+    private Resource parent;
+    private List<Resource> children;
+
+    public static final Comparator<Resource> sortByPriorityAsc =
+            Comparator.comparingInt(Resource::getProcessingPriority);
+    public static final Comparator<Resource> sortByPriorityDesc =
+            Comparator.comparingInt(x -> -x.getProcessingPriority());
+
+    public Resource(WorkflowType resourceType, String resourceId, boolean generated, Resource parent) {
         this.resourceId = resourceId;
         this.resourceType = resourceType;
         this.generated = generated;
+        this.processingPriority = 0;
+        this.children = new ArrayList<>();
+        this.parent = parent;
+        if (parent != null)
+            this.parent.children.add(this);
     }
 
     public String getResourceId() {
@@ -100,4 +125,56 @@ public class Resource {
     public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
         this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
     }
+
+    public String getInstanceName() {
+        return instanceName;
+    }
+
+    public void setInstanceName(String instanceName) {
+        this.instanceName = instanceName;
+    }
+
+    public String getModelInvariantId() {
+        return modelInvariantId;
+    }
+
+    public void setModelInvariantId(String modelInvariantId) {
+        this.modelInvariantId = modelInvariantId;
+    }
+
+    public String getModelVersionId() {
+        return modelVersionId;
+    }
+
+    public void setModelVersionId(String modelVersionId) {
+        this.modelVersionId = modelVersionId;
+    }
+
+    public String getModelCustomizationId() {
+        return modelCustomizationId;
+    }
+
+    public void setModelCustomizationId(String modelCustomizationId) {
+        this.modelCustomizationId = modelCustomizationId;
+    }
+
+    public int getProcessingPriority() {
+        return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
+    }
+
+    public void setProcessingPriority(int processingPriority) {
+        this.processingPriority = processingPriority;
+    }
+
+    public Resource getParent() {
+        return this.parent;
+    }
+
+    public List<Resource> getChildren() {
+        return this.children;
+    }
+
+    public Boolean hasParent() {
+        return parent != null;
+    }
 }