package com.google.graphgeckos.dashboard.storage;

import com.google.cloud.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.cloud.gcp.data.datastore.core.mapping.Entity;
import org.springframework.cloud.gcp.data.datastore.core.mapping.Unindexed;
import org.springframework.data.annotation.Id;

/**
 * Represents the response json with the aggregated buildbot data.
 */
@Entity(name = "revision")
public class BuildInfo {

  // Git commit hash
  @Id
  @Field(name = "commitHash")
  private final String commitHash;
  // time of the Git commit push
  @Field(name = "timestamp")
  private final Timestamp timestamp;
  // name of the branch
  @Field(name = "branch")
  private final String branch;

  @Field(name = "builders")
  @Unindexed
  private final List<Builder> builders;

  BuildInfo(ParsedGitData creationData) {
    this.commitHash = creationData.getCommitHash();
    this.timestamp = creationData.getTimestamp();
    this.branch = creationData.getBranch();
    this.builders = new ArrayList<>();
  }

  /**
   * Returns Git commit hash of the tested changes commit.
   */
  public String getCommitHash() {
    return commitHash;
  }

  /**
   * Returns time of when the tested commit was pushed (the time is fetched from the Git API).
   */
  public Timestamp getTimestamp() {
    return timestamp;
  }

  /**
   * Returns link to to the Git repository where the tested changes were made.
   */
  public String getRepository() {
    return repository;
  }

  /**
   * Returns name of the Git branch where the tested changes were made.
   */
  public String getBranch() {
    return branch;
  }

  /**
   * Returns builders which tested the changes.
   */
  public List<Builder> getBuilders() {
    return builders;
  }

}

@@ -1,430 +1,1405 @@
-package com.google.graphgeckos.dashboard.storage;%0A%0Aimport com.google.cloud.Timestamp;%0Aimport java.util.ArrayList;%0Aimport java.util.Date;%0Aimport java.util.List;%0Aimport org.springframework.cloud.gcp.data.datastore.core.mapping.Entity;%0Aimport org.springframework.cloud.gcp.data.datastore.core.mapping.Unindexed;%0Aimport org.springframework.data.annotation.Id;%0A%0A/**%0A * Represents the response json with the aggregated buildbot data
+// Copyright 2020 Google LLC%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     https://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.graphgeckos.dashboard.storage;%0A%0Aimport com.google.cloud.Timestamp;%0Aimport java.util.ArrayList;%0Aimport java.util.Date;%0Aimport java.util.List;%0Aimport org.springframework.cloud.gcp.data.datastore.core.mapping.Entity;%0Aimport org.springframework.cloud.gcp.data.datastore.core.mapping.Unindexed;%0Aimport org.springframework.data.annotation.Id;%0A%0A/**%0A * This class encapsulates all the information gathered about a specific revision.%0A * Information included: %0A *    * commit hash%0A *    * timestamp%0A *    * branch%0A *    * information from builders:%0A *          - builder name%0A *          - compile logs%0A *          - compilation status%0A *%0A * This class is used to facilitate Datastore I/O operations through Spring Cloud API,%0A * and to transfer the data from the DataRepository to the REST API component
 .%0A *
@@ -1457,29 +1457,8 @@
  %7B%0A%0A
-  // Git commit hash%0A
   @I
@@ -1528,40 +1528,8 @@
 sh;%0A
-  // time of the Git commit push
 %0A  @
@@ -1595,31 +1595,8 @@
 mp;%0A
-  // name of the branch
 %0A  @
@@ -1732,16 +1732,271 @@
 lders;%0A%0A
+  /**%0A   * Converts a ParsedGitData object to a BuildInfo object. This is used for adding%0A   * entries to the Google Cloud Datastore, from the Git commit information received,%0A   * and leaving the %7B@Code builders%7D field as empty, for later updates.%0A   */%0A
   BuildI
@@ -2230,23 +2230,30 @@
 **%0A   * 
-Returns
+Getter for the
  Git com
@@ -2272,29 +2272,77 @@
 the 
-tested changes commit
+associated revision.%0A   *%0A   * @return the commitHash. Cannot be null
 .%0A  
@@ -2443,23 +2443,16 @@
 hen the 
-tested 
 commit w
@@ -2465,46 +2465,94 @@
 hed 
-(the time is fetched from the Git API)
+as a com.google.cloud.Timestamp value.%0A   *%0A   * @return the timestamp. Cannot be null
 .%0A  
@@ -2641,218 +2641,106 @@
 rns 
-link to to the Git repository where the tested changes were made.%0A   */%0A  public String getRepository() %7B%0A    return repository;%0A  %7D%0A%0A  /*
+name of the Git branch where the revision was pushed.%0A   
 *%0A   * 
-R
+@r
 eturn
-s name of
  the 
-Git 
 branch
- where the tested changes were made
+. Cannot be null
 .%0A  
@@ -2831,19 +2831,22 @@
 s which 
-tes
+attemp
 ted the 
@@ -2850,13 +2850,112 @@
 he c
-hange
+ompilation of the revision.%0A   *%0A   * @return the list of builders. Cannot be null, neither it's element
 s.%0A 

change documentation for BuildInfo