Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-api / src / main / java / org / openecomp / sdc / vendorlicense / dao / types / EntitlementPoolEntity.java
index 2b7b3a6..6c4ba90 100644 (file)
@@ -26,6 +26,9 @@ import com.datastax.driver.mapping.annotations.Enumerated;
 import com.datastax.driver.mapping.annotations.Frozen;
 import com.datastax.driver.mapping.annotations.PartitionKey;
 import com.datastax.driver.mapping.annotations.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorlicense.VendorLicenseUtil;
 import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml;
 import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
 import org.openecomp.sdc.vendorlicense.dao.types.xml.OperationalScopeForXml;
@@ -40,6 +43,8 @@ import java.util.Set;
 
 @Table(keyspace = "dox", name = "entitlement_pool")
 public class EntitlementPoolEntity implements VersionableEntity {
+
+  private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
   private static final String ENTITY_TYPE = "Entitlement Pool";
 
   @PartitionKey
@@ -201,7 +206,7 @@ public class EntitlementPoolEntity implements VersionableEntity {
   }
 
   public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
-    if(operationalScope != null) {
+    if (operationalScope != null) {
       operationalScope.resolveEnum(OperationalScope.class);
     }
     this.operationalScope = operationalScope;
@@ -220,7 +225,8 @@ public class EntitlementPoolEntity implements VersionableEntity {
   }
 
   /**
-   *  Gets version for artifact.
+   * Gets version for artifact.
+   *
    * @return version in format suitable for artifact
    */
   public String getVersionForArtifact() {
@@ -251,17 +257,18 @@ public class EntitlementPoolEntity implements VersionableEntity {
     this.limits = limits;
   }
 
-  public LimitForXml getSPLimits(){
-    if(limits != null){
+  public LimitForXml getSPLimits() {
+    if (limits != null) {
       Set<LimitXml> hs = new HashSet<>();
-      for(LimitEntity obj : limits){
-        if(obj.getType().equals(LimitType.ServiceProvider)){
+      for (LimitEntity obj : limits) {
+        if (obj.getType().equals(LimitType.ServiceProvider)) {
           LimitXml xmlObj = new LimitXml();
           xmlObj.setDescription(obj.getDescription());
           xmlObj.setMetric(obj.getMetric());
           xmlObj.setValues(obj.getValue());
           xmlObj.setUnit(obj.getUnit());
-          xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+          xmlObj.setAggregationFunction(
+              obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
           xmlObj.setTime(obj.getTime());
           hs.add(xmlObj);
         }
@@ -274,17 +281,18 @@ public class EntitlementPoolEntity implements VersionableEntity {
     return null;
   }
 
-  public LimitForXml getVendorLimits(){
-    if(limits != null){
+  public LimitForXml getVendorLimits() {
+    if (limits != null) {
       Set<LimitXml> hs = new HashSet<>();
-      for(LimitEntity obj : limits){
-        if(obj.getType().equals(LimitType.Vendor)){
+      for (LimitEntity obj : limits) {
+        if (obj.getType().equals(LimitType.Vendor)) {
           LimitXml xmlObj = new LimitXml();
           xmlObj.setDescription(obj.getDescription());
           xmlObj.setMetric(obj.getMetric());
           xmlObj.setValues(obj.getValue());
           xmlObj.setUnit(obj.getUnit());
-          xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+          xmlObj.setAggregationFunction(
+              obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
           xmlObj.setTime(obj.getTime());
           hs.add(xmlObj);
         }
@@ -324,7 +332,9 @@ public class EntitlementPoolEntity implements VersionableEntity {
         && Objects.equals(operationalScope, that.operationalScope)
         && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups)
         && Objects.equals(startDate, that.startDate)
-        && Objects.equals(expiryDate, that.expiryDate);
+        && Objects.equals(expiryDate, that.expiryDate)
+        && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
+        && Objects.equals(version, that.version);
   }
 
   @Override
@@ -354,7 +364,7 @@ public class EntitlementPoolEntity implements VersionableEntity {
   public OperationalScopeForXml getOperationalScopeForArtifact() {
     OperationalScopeForXml obj = new OperationalScopeForXml();
     if (operationalScope != null) {
-      if(operationalScope.getResults().size() > 0) {
+      if (operationalScope.getResults().size() > 0) {
         obj.setValue(operationalScope.getResults());
       }
     }
@@ -369,4 +379,27 @@ public class EntitlementPoolEntity implements VersionableEntity {
   public String getManufacturerReferenceNumber() {
     return manufacturerReferenceNumber;
   }
+
+  public String getIsoFormatStartDate() {
+    mdcDataDebugMessage.debugEntryMessage("start date", startDate);
+    String isoFormatStartDate = null;
+    if (!StringUtils.isEmpty(startDate)) {
+      isoFormatStartDate = VendorLicenseUtil.getIsoFormatDate(startDate);
+      mdcDataDebugMessage.debugExitMessage("start date", "iso format start date", startDate,
+          isoFormatStartDate);
+    }
+    return isoFormatStartDate;
+  }
+
+
+  public String getIsoFormatExpiryDate() {
+    mdcDataDebugMessage.debugEntryMessage("expiry date", expiryDate);
+    String isoFormatExpDate = null;
+    if (!StringUtils.isEmpty(expiryDate)) {
+      isoFormatExpDate = VendorLicenseUtil.getIsoFormatDate(expiryDate);
+      mdcDataDebugMessage.debugExitMessage("expiry date", "iso format expiry date", expiryDate,
+          isoFormatExpDate);
+    }
+    return isoFormatExpDate;
+  }
 }