aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-database/src/main
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2007-10-21 17:30:07 +0000
committerMaria Odea B. Ching <oching@apache.org>2007-10-21 17:30:07 +0000
commit21a61ab5f9c0a139bb25a64c7d8136af6a00dc96 (patch)
treea461952e7cada7b45eca459e7089262f1121adc0 /archiva-database/src/main
parent1d6c1b9d0aab92bf85ec37dc24900bf890410838 (diff)
downloadarchiva-21a61ab5f9c0a139bb25a64c7d8136af6a00dc96.tar.gz
archiva-21a61ab5f9c0a139bb25a64c7d8136af6a00dc96.zip
[MRM-265]
- added method for deleting the artifacts in the db when a repo is deleted - also deleted repo scan statistics when the repo is deleted - created DAO that does retrieving, deleting and adding of RepositoryContentStatistics to the db - added and updated tests git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@586919 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-database/src/main')
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java6
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java49
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java14
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java67
4 files changed, 134 insertions, 2 deletions
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
index 18b1821d3..d38aea1a3 100644
--- a/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
@@ -22,6 +22,8 @@ package org.apache.maven.archiva.database;
import java.io.Serializable;
import java.util.List;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
/**
* ArchivaDAO - The interface for all content within the database.
*
@@ -47,10 +49,12 @@ public interface ArchivaDAO
* @return the post-serialized object.
*/
Object save( Serializable obj );
-
+
ArtifactDAO getArtifactDAO();
ProjectModelDAO getProjectModelDAO();
RepositoryProblemDAO getRepositoryProblemDAO();
+
+ RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO();
}
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java
new file mode 100644
index 000000000..dc3990980
--- /dev/null
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java
@@ -0,0 +1,49 @@
+package org.apache.maven.archiva.database.constraints;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * RepositoryContentStatisticsByRepositoryConstraint
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class RepositoryContentStatisticsByRepositoryConstraint
+ extends AbstractDeclarativeConstraint
+{
+ private String whereClause;
+
+ public RepositoryContentStatisticsByRepositoryConstraint( String repoId )
+ {
+ whereClause = "repositoryId == repoId";
+ declParams = new String[] { "String repoId" };
+ params = new Object[] { repoId };
+ }
+
+ public String getSortColumn()
+ {
+ return "whenGathered";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
index 639106184..680c395d8 100644
--- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.database.jdo;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
import org.apache.maven.archiva.database.RepositoryProblemDAO;
import org.apache.maven.archiva.database.SimpleConstraint;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -60,6 +61,12 @@ public class JdoArchivaDAO
* @plexus.requirement role-hint="jdo"
*/
private RepositoryProblemDAO repositoryProblemDAO;
+
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO;
+
public List query( SimpleConstraint constraint )
{
@@ -70,7 +77,7 @@ public class JdoArchivaDAO
{
return jdo.saveObject( obj );
}
-
+
public ArtifactDAO getArtifactDAO()
{
return artifactDAO;
@@ -85,4 +92,9 @@ public class JdoArchivaDAO
{
return repositoryProblemDAO;
}
+
+ public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO()
+ {
+ return repositoryContentStatisticsDAO;
+ }
}
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java
new file mode 100644
index 000000000..00475ed9e
--- /dev/null
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryContentStatisticsDAO.java
@@ -0,0 +1,67 @@
+package org.apache.maven.archiva.database.jdo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.List;
+
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO;
+import org.apache.maven.archiva.model.RepositoryContentStatistics;
+
+/**
+ * JdoRepositoryContentStatisticsDAO
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ *
+ * @plexus.component role-hint="jdo"
+ */
+public class JdoRepositoryContentStatisticsDAO
+ implements RepositoryContentStatisticsDAO
+{
+ /**
+ * @plexus.requirement role-hint="archiva"
+ */
+ private JdoAccess jdo;
+
+ public void deleteRepositoryContentStatistics( RepositoryContentStatistics stats )
+ throws ArchivaDatabaseException
+ {
+ jdo.removeObject( stats );
+ }
+
+ public List queryRepositoryContentStatistics( Constraint constraint )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ List results = jdo.queryObjects( RepositoryContentStatistics.class, constraint );
+
+ return results;
+ }
+
+ public RepositoryContentStatistics saveRepositoryContentStatistics( RepositoryContentStatistics stats )
+ {
+ RepositoryContentStatistics savedStats = (RepositoryContentStatistics) jdo.saveObject( stats );
+
+ return savedStats;
+ }
+
+}