1 package org.apache.archiva.metadata.repository.stats;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import java.text.DateFormat;
23 import java.text.SimpleDateFormat;
24 import java.util.Date;
25 import java.util.HashMap;
28 import org.apache.archiva.metadata.model.MetadataFacet;
30 public class RepositoryStatistics
31 implements MetadataFacet
33 private Date scanEndTime;
35 private Date scanStartTime;
37 private long totalArtifactCount;
39 private long totalArtifactFileSize;
41 private long totalFileCount;
43 private long totalGroupCount;
45 private long totalProjectCount;
47 private long newFileCount;
49 public static String FACET_ID = "org.apache.archiva.metadata.repository.stats";
51 static final DateFormat SCAN_TIMESTAMP = new SimpleDateFormat( "yyyyMMdd.HHmmss.SSS" );
53 public Date getScanEndTime()
58 public void setScanEndTime( Date scanEndTime )
60 this.scanEndTime = scanEndTime;
63 public Date getScanStartTime()
68 public void setScanStartTime( Date scanStartTime )
70 this.scanStartTime = scanStartTime;
73 public long getTotalArtifactCount()
75 return totalArtifactCount;
78 public void setTotalArtifactCount( long totalArtifactCount )
80 this.totalArtifactCount = totalArtifactCount;
83 public long getTotalArtifactFileSize()
85 return totalArtifactFileSize;
88 public void setTotalArtifactFileSize( long totalArtifactFileSize )
90 this.totalArtifactFileSize = totalArtifactFileSize;
93 public long getTotalFileCount()
95 return totalFileCount;
98 public void setTotalFileCount( long totalFileCount )
100 this.totalFileCount = totalFileCount;
103 public long getTotalGroupCount()
105 return totalGroupCount;
108 public void setTotalGroupCount( long totalGroupCount )
110 this.totalGroupCount = totalGroupCount;
113 public long getTotalProjectCount()
115 return totalProjectCount;
118 public void setTotalProjectCount( long totalProjectCount )
120 this.totalProjectCount = totalProjectCount;
123 public void setNewFileCount( long newFileCount )
125 this.newFileCount = newFileCount;
128 public long getNewFileCount()
133 public long getDuration()
135 return scanEndTime.getTime() - scanStartTime.getTime();
138 public String getFacetId()
143 public String getName()
145 return SCAN_TIMESTAMP.format( scanStartTime );
148 public Map<String, String> toProperties()
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 ) );
162 public void fromProperties( Map<String, String> properties )
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" ) );