Merge branch 'recursive-orch'
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / workflow / tasks / Resource.java
index 6fcad95..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 {
-
-       private String resourceId;
-       private WorkflowType resourceType;
-       private boolean generated;
-       private boolean baseVfModule;
-       private String virtualLinkKey;
-       
-       public Resource(WorkflowType resourceType, String resourceId, boolean generated){
-               this.resourceId = resourceId;
-               this.resourceType = resourceType;
-               this.generated = generated;
-       }
-       
-       public String getResourceId() {
-               return resourceId;
-       }
-       public void setResourceId(String resourceId) {
-               this.resourceId = resourceId;
-       }
-       public WorkflowType getResourceType() {
-               return resourceType;
-       }
-       public void setResourceType(WorkflowType resourceType) {
-               this.resourceType = resourceType;
-       }
-       public boolean isGenerated() {
-               return generated;
-       }
-       public void setGenerated(boolean generated) {
-               this.generated = generated;
-       }
-       public boolean isBaseVfModule() {
-               return baseVfModule;
-       }
-       public void setBaseVfModule(boolean baseVfModule) {
-               this.baseVfModule = baseVfModule;
-       }
-       public String getVirtualLinkKey() {
-               return virtualLinkKey;
-       }
-       public void setVirtualLinkKey(String virtualLinkKey) {
-               this.virtualLinkKey = virtualLinkKey;
-       }
+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;
+    private boolean baseVfModule;
+    private String virtualLinkKey;
+    private String vnfCustomizationId;
+    private String vfModuleCustomizationId;
+    private String cvnfModuleCustomizationId;
+    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() {
+        return resourceId;
+    }
+
+    public void setResourceId(String resourceId) {
+        this.resourceId = resourceId;
+    }
+
+    public WorkflowType getResourceType() {
+        return resourceType;
+    }
+
+    public void setResourceType(WorkflowType resourceType) {
+        this.resourceType = resourceType;
+    }
+
+    public boolean isGenerated() {
+        return generated;
+    }
+
+    public void setGenerated(boolean generated) {
+        this.generated = generated;
+    }
+
+    public boolean isBaseVfModule() {
+        return baseVfModule;
+    }
+
+    public void setBaseVfModule(boolean baseVfModule) {
+        this.baseVfModule = baseVfModule;
+    }
+
+    public String getVirtualLinkKey() {
+        return virtualLinkKey;
+    }
+
+    public void setVirtualLinkKey(String virtualLinkKey) {
+        this.virtualLinkKey = virtualLinkKey;
+    }
+
+    public String getVnfCustomizationId() {
+        return vnfCustomizationId;
+    }
+
+    public void setVnfCustomizationId(String vnfCustomizationId) {
+        this.vnfCustomizationId = vnfCustomizationId;
+    }
+
+    public String getVfModuleCustomizationId() {
+        return vfModuleCustomizationId;
+    }
+
+    public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
+        this.vfModuleCustomizationId = vfModuleCustomizationId;
+    }
+
+    public String getCvnfModuleCustomizationId() {
+        return cvnfModuleCustomizationId;
+    }
+
+    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;
+    }
 }