1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you
5  * may not use this file except in compliance with the License. You may
6  * obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13  * implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 
17 package com.android.vts.entity;
18 
19 import com.googlecode.objectify.Key;
20 
21 import com.googlecode.objectify.annotation.Cache;
22 import com.googlecode.objectify.annotation.Entity;
23 import com.googlecode.objectify.annotation.Id;
24 import com.googlecode.objectify.annotation.Index;
25 import com.googlecode.objectify.annotation.Parent;
26 import lombok.EqualsAndHashCode;
27 import lombok.Getter;
28 import lombok.NoArgsConstructor;
29 import lombok.Setter;
30 
31 import java.util.List;
32 
33 import static com.googlecode.objectify.ObjectifyService.ofy;
34 
35 /** Entity Class for CodeCoverageFile */
36 @Cache
37 @Entity(name = "CodeCoverageFile")
38 @EqualsAndHashCode(of = "id")
39 @NoArgsConstructor
40 public class CodeCoverageFileEntity implements DashboardEntity {
41 
42     /** CodeCoverageFileEntity testName field */
43     @Id @Getter @Setter Long id;
44 
45     @Parent
46     @Getter @Setter private Key<?> coverageParent;
47 
48     /** CodeCoverageFileEntity filePath field */
49     @Getter @Setter String filePath;
50 
51     /** CodeCoverageFileEntity group field */
52     @Getter @Setter String group;
53 
54     /** CodeCoverageFileEntity lineCoverage field */
55     @Getter @Setter List<Long> lineCoverage;
56 
57     /** CodeCoverageFileEntity coveredCount field */
58     @Getter @Setter long coveredCount;
59 
60     /** CodeCoverageFileEntity totalCount field */
61     @Getter @Setter long totalCount;
62 
63     /** CodeCoverageFileEntity projectName field */
64     @Getter @Setter String projectName;
65 
66     /** CodeCoverageFileEntity projectVersion field */
67     @Getter @Setter String projectVersion;
68 
69     /** CodeCoverageFileEntity isIgnored field */
70     @Index
71     @Getter @Setter Boolean isIgnored;
72 
73     /** Constructor function for CodeCoverageFileEntity Class */
CodeCoverageFileEntity( long id, Key<?> coverageParent, String filePath, String group, List<Long> lineCoverage, long coveredCount, long totalCount, String projectName, String projectVersion)74     public CodeCoverageFileEntity(
75             long id,
76             Key<?> coverageParent,
77             String filePath,
78             String group,
79             List<Long> lineCoverage,
80             long coveredCount,
81             long totalCount,
82             String projectName,
83             String projectVersion) {
84         this.id = id;
85         this.coverageParent = coverageParent;
86         this.filePath = filePath;
87         this.group = group;
88         this.lineCoverage = lineCoverage;
89         this.coveredCount = coveredCount;
90         this.totalCount = totalCount;
91         this.projectName = projectName;
92         this.projectVersion = projectVersion;
93     }
94 
95     /** Saving function for the instance of this class */
96     @Override
save()97     public Key<CodeCoverageFileEntity> save() {
98         this.isIgnored = false;
99         return ofy().save().entity(this).now();
100     }
101 }
102