]> source.dussan.org Git - archiva.git/blob
272d524ddf2c9a520e0666ef1bffad029dca82e4
[archiva.git] /
1 package org.apache.archiva.metadata.repository.stats;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
24 import java.util.Date;
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import org.apache.archiva.metadata.model.MetadataFacet;
29
30 public class RepositoryStatistics
31     implements MetadataFacet
32 {
33     private Date scanEndTime;
34
35     private Date scanStartTime;
36
37     private long totalArtifactCount;
38
39     private long totalArtifactFileSize;
40
41     private long totalFileCount;
42
43     private long totalGroupCount;
44
45     private long totalProjectCount;
46
47     private long newFileCount;
48
49     public static String FACET_ID = "org.apache.archiva.metadata.repository.stats";
50
51     static final DateFormat SCAN_TIMESTAMP = new SimpleDateFormat( "yyyyMMdd.HHmmss.SSS" );
52
53     public Date getScanEndTime()
54     {
55         return scanEndTime;
56     }
57
58     public void setScanEndTime( Date scanEndTime )
59     {
60         this.scanEndTime = scanEndTime;
61     }
62
63     public Date getScanStartTime()
64     {
65         return scanStartTime;
66     }
67
68     public void setScanStartTime( Date scanStartTime )
69     {
70         this.scanStartTime = scanStartTime;
71     }
72
73     public long getTotalArtifactCount()
74     {
75         return totalArtifactCount;
76     }
77
78     public void setTotalArtifactCount( long totalArtifactCount )
79     {
80         this.totalArtifactCount = totalArtifactCount;
81     }
82
83     public long getTotalArtifactFileSize()
84     {
85         return totalArtifactFileSize;
86     }
87
88     public void setTotalArtifactFileSize( long totalArtifactFileSize )
89     {
90         this.totalArtifactFileSize = totalArtifactFileSize;
91     }
92
93     public long getTotalFileCount()
94     {
95         return totalFileCount;
96     }
97
98     public void setTotalFileCount( long totalFileCount )
99     {
100         this.totalFileCount = totalFileCount;
101     }
102
103     public long getTotalGroupCount()
104     {
105         return totalGroupCount;
106     }
107
108     public void setTotalGroupCount( long totalGroupCount )
109     {
110         this.totalGroupCount = totalGroupCount;
111     }
112
113     public long getTotalProjectCount()
114     {
115         return totalProjectCount;
116     }
117
118     public void setTotalProjectCount( long totalProjectCount )
119     {
120         this.totalProjectCount = totalProjectCount;
121     }
122
123     public void setNewFileCount( long newFileCount )
124     {
125         this.newFileCount = newFileCount;
126     }
127
128     public long getNewFileCount()
129     {
130         return newFileCount;
131     }
132
133     public long getDuration()
134     {
135         return scanEndTime.getTime() - scanStartTime.getTime();
136     }
137
138     public String getFacetId()
139     {
140         return FACET_ID;
141     }
142
143     public String getName()
144     {
145         return SCAN_TIMESTAMP.format( scanStartTime );
146     }
147
148     public Map<String, String> toProperties()
149     {
150         Map<String, String> properties = new HashMap<String, String>();
151         properties.put( "scanEndTime", String.valueOf( scanEndTime.getTime() ) );
152         properties.put( "scanStartTime", String.valueOf( scanStartTime.getTime() ) );
153         properties.put( "totalArtifactCount", String.valueOf( totalArtifactCount ) );
154         properties.put( "totalArtifactFileSize", String.valueOf( totalArtifactFileSize ) );
155         properties.put( "totalFileCount", String.valueOf( totalFileCount ) );
156         properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) );
157         properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) );
158         properties.put( "newFileCount", String.valueOf( newFileCount ) );
159         return properties;
160     }
161
162     public void fromProperties( Map<String, String> properties )
163     {
164         scanEndTime = new Date( Long.valueOf( properties.get( "scanEndTime" ) ) );
165         scanStartTime = new Date( Long.valueOf( properties.get( "scanStartTime" ) ) );
166         totalArtifactCount = Long.valueOf( properties.get( "totalArtifactCount" ) );
167         totalArtifactFileSize = Long.valueOf( properties.get( "totalArtifactFileSize" ) );
168         totalFileCount = Long.valueOf( properties.get( "totalFileCount" ) );
169         totalGroupCount = Long.valueOf( properties.get( "totalGroupCount" ) );
170         totalProjectCount = Long.valueOf( properties.get( "totalProjectCount" ) );
171         newFileCount = Long.valueOf( properties.get( "newFileCount" ) );
172     }
173 }