Author: brett
Date: Fri Aug 3 09:02:00 2007
New Revision: 562511
URL: http://svn.apache.org/viewvc?view=rev&rev=562511
Log:
[MRM-329] revised reporting actions
Submitted by: Teodoro Cue
Added:
maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java
(with props)
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java
(with props)
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
(with props)
Removed:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByArtifactIdConstraint.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/jasperreports/
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AbstractReportAction.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AllProblematicArtifactsAction.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByArtifactIdAction.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByGroupIdAction.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByRepositoryIdAction.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/blankReport.jsp
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp
Modified:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/
(props changed)
Added:
maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java
(added)
+++
maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,79 @@
+package org.apache.maven.archiva.model;
+
+/*
+ * 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.
+ */
+
+/**
+ * RepositoryProblemReport
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryProblemReport
+ extends RepositoryProblem
+{
+ private static final long serialVersionUID = 4990893576717148324L;
+
+ protected String groupURL;
+
+ protected String artifactURL;
+
+ protected String versionURL;
+
+ public RepositoryProblemReport( RepositoryProblem repositoryProblem )
+ {
+ setGroupId( repositoryProblem.getGroupId() );
+ setArtifactId( repositoryProblem.getArtifactId() );
+ setVersion( repositoryProblem.getVersion() );
+ setMessage( repositoryProblem.getMessage() );
+ setOrigin( repositoryProblem.getOrigin() );
+ setPath( repositoryProblem.getPath() );
+ setType( repositoryProblem.getType() );
+ }
+
+ public void setGroupURL( String groupURL )
+ {
+ this.groupURL = groupURL;
+ }
+
+ public String getGroupURL()
+ {
+ return groupURL;
+ }
+
+ public void setArtifactURL( String artifactURL )
+ {
+ this.artifactURL = artifactURL;
+ }
+
+ public String getArtifactURL()
+ {
+ return artifactURL;
+ }
+
+ public void setVersionURL( String versionURL )
+ {
+ this.versionURL = versionURL;
+ }
+
+ public String getVersionURL()
+ {
+ return versionURL;
+ }
+}
Modified:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java?view=diff&rev=562511&r1=562510&r2=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java
(original)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java
Fri Aug 3 09:02:00 2007
@@ -20,84 +20,85 @@
*/
/**
- * DeclarativeConstraint
+ * DeclarativeConstraint
*
* @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
* @version $Id$
*/
-public interface DeclarativeConstraint extends Constraint
+public interface DeclarativeConstraint
+ extends Constraint
{
/**
* Get the declared imports used for this query. (optional)
- *
+ * <p/>
* NOTE: This is DAO implementation specific.
- *
+ *
* @return the imports. (can be null)
*/
public abstract String[] getDeclaredImports();
/**
* Get the declared parameters used for this query. (optional)
- *
+ * <p/>
* NOTE: This is DAO implementation specific.
- *
+ *
* @return the parameters. (can be null)
*/
public abstract String[] getDeclaredParameters();
-
+
/**
* The JDOQL filter to apply to the query. (optional)
- *
+ * <p/>
* NOTE: This is DAO implementation specific.
- *
+ *
* @return the filter to apply. (can be null)
*/
public abstract String getFilter();
/**
* Get the parameters used for this query. (required if using [EMAIL
PROTECTED] #getDeclaredParameters()} )
- *
+ * <p/>
* NOTE: This is DAO implementation specific.
- *
+ *
* @return the parameters. (can be null)
*/
public abstract Object[] getParameters();
/**
* Get the sort direction name.
- *
+ *
* @return the sort direction name. ("ASC" or "DESC") (only valid if
[EMAIL PROTECTED] #getSortColumn()} is specified.)
*/
public abstract String getSortDirection();
/**
* Get the sort column name.
- *
+ *
* @return the sort column name. (can be null)
*/
public abstract String getSortColumn();
-
+
/**
* Get the variables used within the query.
- *
+ * <p/>
* NOTE: This is DAO implementation specific.
- *
+ *
* @return the variables used within the query.
*/
public abstract String[] getVariables();
/**
* Get the SELECT WHERE (condition) value for the constraint.
- *
+ *
* @return the equivalent of the SELECT WHERE (condition) value for this
constraint. (can be null)
*/
public abstract String getWhereCondition();
/**
* Get the declared range used for this query. (optional)
- *
+ * <p/>
* NOTE: This is DAO implementation specific.
- *
+ *
* @return the range. (can be null)
*/
public abstract int[] getRange();
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,50 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.Constraint;
+
+/**
+ * RangeConstraint
+ */
+public class RangeConstraint
+ extends AbstractDeclarativeConstraint
+ implements Constraint
+{
+ public RangeConstraint()
+ {
+ this.range = null;
+ }
+
+ public RangeConstraint( int[] range )
+ {
+ this.range = range;
+ }
+
+ public String getSortColumn()
+ {
+ return null;
+ }
+
+ public String getWhereCondition()
+ {
+ return null;
+ }
+}
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,61 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.Constraint;
+
+/**
+ * RepositoryProblemByGroupIdConstraint
+ */
+public class RepositoryProblemByGroupIdConstraint
+ extends RangeConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ private void createWhereClause( String desiredGroupId )
+ {
+ whereClause = "groupId == desiredGroupId";
+ declParams = new String[]{"String desiredGroupId"};
+ params = new Object[]{desiredGroupId};
+ }
+
+ public RepositoryProblemByGroupIdConstraint( String desiredGroupId )
+ {
+ super();
+ createWhereClause( desiredGroupId );
+ }
+
+ public RepositoryProblemByGroupIdConstraint( int[] range, String
desiredGroupId )
+ {
+ super( range );
+ createWhereClause( desiredGroupId );
+ }
+
+ public String getSortColumn()
+ {
+ return "artifactId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,61 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.Constraint;
+
+/**
+ * RepositoryProblemByRepositoryIdConstraint
+ */
+public class RepositoryProblemByRepositoryIdConstraint
+ extends RangeConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ private void createWhereClause( String desiredRepositoryId )
+ {
+ whereClause = "repositoryId == desiredRepositoryId";
+ declParams = new String[]{"String desiredRepositoryId"};
+ params = new Object[]{desiredRepositoryId};
+ }
+
+ public RepositoryProblemByRepositoryIdConstraint( String
desiredRepositoryId )
+ {
+ super();
+ createWhereClause( desiredRepositoryId );
+ }
+
+ public RepositoryProblemByRepositoryIdConstraint( int[] range, String
desiredRepositoryId )
+ {
+ super( range );
+ createWhereClause( desiredRepositoryId );
+ }
+
+ public String getSortColumn()
+ {
+ return "groupId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,61 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.Constraint;
+
+/**
+ * RepositoryProblemConstraint
+ */
+public class RepositoryProblemConstraint
+ extends RangeConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ private void createWhereClause( String desiredGroupId, String
desiredRepositoryId )
+ {
+ whereClause = "groupId == desiredGroupId && repositoryId ==
desiredRepositoryId";
+ declParams = new String[]{"String desiredGroupId", "String
desiredRepositoryId"};
+ params = new Object[]{desiredGroupId, desiredRepositoryId};
+ }
+
+ public RepositoryProblemConstraint( String desiredGroupId, String
desiredRepositoryId )
+ {
+ super();
+ createWhereClause( desiredGroupId, desiredRepositoryId );
+ }
+
+ public RepositoryProblemConstraint( int[] range, String desiredGroupId,
String desiredRepositoryId )
+ {
+ super( range );
+ createWhereClause( desiredGroupId, desiredRepositoryId );
+ }
+
+ public String getSortColumn()
+ {
+ return "artifactId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,57 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.Constraint;
+
+/**
+ * UniqueFieldConstraint
+ */
+public class UniqueFieldConstraint
+ extends AbstractSimpleConstraint
+ implements Constraint
+{
+ private String sql;
+
+ public UniqueFieldConstraint( String className, String fieldName )
+ {
+ sql = "SELECT " + fieldName + " FROM " + className + " GROUP BY " +
fieldName + " ORDER BY " + fieldName +
+ " ASCENDING";
+ }
+
+ public UniqueFieldConstraint( String className, String fieldName, String
fieldNamePrefix )
+ {
+ sql = "SELECT " + fieldName + " FROM " + className + " WHERE " +
fieldName +
+ ".startsWith( fieldPrefix ) PARAMETERS String fieldPrefix GROUP BY
" + fieldName + " ORDER BY " +
+ fieldName + " ASCENDING";
+
+ super.params = new Object[]{fieldNamePrefix};
+ }
+
+ public Class getResultClass()
+ {
+ return String.class;
+ }
+
+ public String getSelectSql()
+ {
+ return sql;
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,88 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+import java.util.List;
+
+/**
+ * RangeConstraintTest
+ */
+public class RangeConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private RepositoryProblemDAO repoProblemDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ repoProblemDao = dao.getRepositoryProblemDAO();
+ }
+
+ public RepositoryProblem createRepoProblem()
+ {
+ RepositoryProblem repoProblem = new RepositoryProblem();
+
+ repoProblem.setGroupId( "groupId" );
+ repoProblem.setArtifactId( "artifactId" );
+ repoProblem.setMessage( "message" );
+ repoProblem.setOrigin( "origin" );
+ repoProblem.setPath( "path" );
+ repoProblem.setRepositoryId( "repositoryId" );
+ repoProblem.setType( "type" );
+ repoProblem.setVersion( "version" );
+
+ return repoProblem;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ repoProblemDao.saveRepositoryProblem( createRepoProblem() );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem() );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem() );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem() );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem() );
+
+ assertConstraint( 0, new RangeConstraint( new int[]{5, 10} ) );
+ assertConstraint( 1, new RangeConstraint( new int[]{0, 1} ) );
+ assertConstraint( 2, new RangeConstraint( new int[]{0, 2} ) );
+ assertConstraint( 3, new RangeConstraint( new int[]{0, 3} ) );
+ assertConstraint( 4, new RangeConstraint( new int[]{0, 4} ) );
+ assertConstraint( 5, new RangeConstraint( new int[]{0, 5} ) );
+ assertConstraint( 5, new RangeConstraint() );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = repoProblemDao.queryRepositoryProblems( constraint );
+ assertNotNull( "Range Constraint: Not Null", results );
+ assertEquals( "Range Constraint: Results.size", expectedHits,
results.size() );
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,93 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+import java.util.List;
+
+/**
+ * RepositoryProblemByGroupIdConstraintTest
+ */
+public class RepositoryProblemByGroupIdConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private static final String GROUP_ID_1 = "org.apache.maven.archiva.test.1";
+
+ private static final String GROUP_ID_2 = "org.apache.maven.archiva.test.2";
+
+ private static final String GROUP_ID_3 = "org.apache.maven.archiva.test.3";
+
+ private RepositoryProblemDAO repoProblemDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ repoProblemDao = dao.getRepositoryProblemDAO();
+ }
+
+ public RepositoryProblem createRepoProblem( String groupId )
+ {
+ RepositoryProblem repoProblem = new RepositoryProblem();
+
+ repoProblem.setGroupId( groupId );
+ repoProblem.setArtifactId( "artifactId" );
+ repoProblem.setMessage( "message" );
+ repoProblem.setOrigin( "origin" );
+ repoProblem.setPath( "path" );
+ repoProblem.setRepositoryId( "repositoryId" );
+ repoProblem.setType( "type" );
+ repoProblem.setVersion( "version" );
+
+ return repoProblem;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1 )
);
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2 )
);
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2 )
);
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 )
);
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 )
);
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 )
);
+
+ assertConstraint( 1, new RepositoryProblemByGroupIdConstraint(
GROUP_ID_1 ) );
+ assertConstraint( 2, new RepositoryProblemByGroupIdConstraint(
GROUP_ID_2 ) );
+ assertConstraint( 3, new RepositoryProblemByGroupIdConstraint(
GROUP_ID_3 ) );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = repoProblemDao.queryRepositoryProblems( constraint );
+ assertNotNull( "Repository Problems by Group Id: Not Null", results );
+ assertEquals( "Repository Problems by Group Id: Results.size",
expectedHits, results.size() );
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,93 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+import java.util.List;
+
+/**
+ * RepositoryProblemByRepositoryIdConstraintTest
+ */
+public class RepositoryProblemByRepositoryIdConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private static final String REPO_ID_1 = "test-repo-1";
+
+ private static final String REPO_ID_2 = "test-repo-2";
+
+ private static final String REPO_ID_3 = "test-repo-3";
+
+ private RepositoryProblemDAO repoProblemDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ repoProblemDao = dao.getRepositoryProblemDAO();
+ }
+
+ public RepositoryProblem createRepoProblem( String repoId )
+ {
+ RepositoryProblem repoProblem = new RepositoryProblem();
+
+ repoProblem.setGroupId( "groupId" );
+ repoProblem.setArtifactId( "artifactId" );
+ repoProblem.setMessage( "message" );
+ repoProblem.setOrigin( "origin" );
+ repoProblem.setPath( "path" );
+ repoProblem.setRepositoryId( repoId );
+ repoProblem.setType( "type" );
+ repoProblem.setVersion( "version" );
+
+ return repoProblem;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_1 ) );
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_2 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_2 ) );
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_3 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_3 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_3 ) );
+
+ assertConstraint( 1, new RepositoryProblemByRepositoryIdConstraint(
REPO_ID_1 ) );
+ assertConstraint( 2, new RepositoryProblemByRepositoryIdConstraint(
REPO_ID_2 ) );
+ assertConstraint( 3, new RepositoryProblemByRepositoryIdConstraint(
REPO_ID_3 ) );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = repoProblemDao.queryRepositoryProblems( constraint );
+ assertNotNull( "Repository Problems by Repository Id: Not Null",
results );
+ assertEquals( "Repository Problems by Repository Id: Results.size",
expectedHits, results.size() );
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,122 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+import java.util.List;
+
+/**
+ * RepositoryProblemConstraintTest
+ */
+public class RepositoryProblemConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private static final String GROUP_ID_1 = "org.apache.maven.archiva.test.1";
+
+ private static final String GROUP_ID_2 = "org.apache.maven.archiva.test.2";
+
+ private static final String GROUP_ID_3 = "org.apache.maven.archiva.test.3";
+
+ private static final String GROUP_ID_4 = "org.apache.maven.archiva.test.4";
+
+ private static final String REPO_ID_1 = "test-repo-1";
+
+ private static final String REPO_ID_2 = "test-repo-2";
+
+ private static final String REPO_ID_3 = "test-repo-3";
+
+ private static final String REPO_ID_4 = "test-repo-4";
+
+ private RepositoryProblemDAO repoProblemDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ repoProblemDao = dao.getRepositoryProblemDAO();
+ }
+
+ public RepositoryProblem createRepoProblem( String groupId, String repoId )
+ {
+ RepositoryProblem repoProblem = new RepositoryProblem();
+
+ repoProblem.setGroupId( groupId );
+ repoProblem.setArtifactId( "artifactId" );
+ repoProblem.setMessage( "message" );
+ repoProblem.setOrigin( "origin" );
+ repoProblem.setPath( "path" );
+ repoProblem.setRepositoryId( repoId );
+ repoProblem.setType( "type" );
+ repoProblem.setVersion( "version" );
+
+ return repoProblem;
+ }
+
+ public void testGroupIdConstraint()
+ throws Exception
+ {
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_1 ) );
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2,
REPO_ID_1 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2,
REPO_ID_1 ) );
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3,
REPO_ID_1 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3,
REPO_ID_1 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3,
REPO_ID_1 ) );
+
+ assertConstraint( 1, new RepositoryProblemConstraint( GROUP_ID_1,
REPO_ID_1 ) );
+ assertConstraint( 2, new RepositoryProblemConstraint( GROUP_ID_2,
REPO_ID_1 ) );
+ assertConstraint( 3, new RepositoryProblemConstraint( GROUP_ID_3,
REPO_ID_1 ) );
+ assertConstraint( 0, new RepositoryProblemConstraint( GROUP_ID_4,
REPO_ID_1 ) );
+ }
+
+ public void testRepoIdConstraint()
+ throws Exception
+ {
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_1 ) );
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_2 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_2 ) );
+
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_3 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_3 ) );
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1,
REPO_ID_3 ) );
+
+ assertConstraint( 1, new RepositoryProblemConstraint( GROUP_ID_1,
REPO_ID_1 ) );
+ assertConstraint( 2, new RepositoryProblemConstraint( GROUP_ID_1,
REPO_ID_2 ) );
+ assertConstraint( 3, new RepositoryProblemConstraint( GROUP_ID_1,
REPO_ID_3 ) );
+ assertConstraint( 0, new RepositoryProblemConstraint( GROUP_ID_1,
REPO_ID_4 ) );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = repoProblemDao.queryRepositoryProblems( constraint );
+ assertNotNull( "Repository Problems: Not Null", results );
+ assertEquals( "Repository Problems: Results.size", expectedHits,
results.size() );
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,117 @@
+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.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
+import org.apache.maven.archiva.database.SimpleConstraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaArtifactModel;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * UniqueFieldConstraintTest
+ */
+public class UniqueFieldConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private static final String GROUP_ID_1 = "org.apache.maven.archiva.test.1";
+
+ private static final String GROUP_ID_2 = "org.apache.maven.archiva.test.2";
+
+ private static final String GROUP_ID_3 = "org.apache.maven.archiva.test.3";
+
+ private ArchivaDAO archivaDao;
+
+ private ArtifactDAO artifactDao;
+
+ private RepositoryProblemDAO repoProblemDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ archivaDao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ artifactDao = archivaDao.getArtifactDAO();
+ repoProblemDao = archivaDao.getRepositoryProblemDAO();
+ }
+
+ public ArchivaArtifact createArtifact( String groupId )
+ {
+ ArchivaArtifact artifact = artifactDao.createArtifact( groupId,
"artifactId", "version", "classifier", "jar" );
+
+ artifact.getModel().setLastModified( new Date() );
+ artifact.getModel().setRepositoryId( "repoId" );
+
+ return artifact;
+ }
+
+ public RepositoryProblem createRepoProblem( String groupId )
+ {
+ RepositoryProblem repoProblem = new RepositoryProblem();
+
+ repoProblem.setGroupId( groupId );
+ repoProblem.setArtifactId( "artifactId" );
+ repoProblem.setMessage( "message" );
+ repoProblem.setOrigin( "origin" );
+ repoProblem.setPath( "path" );
+ repoProblem.setRepositoryId( "repoId" );
+ repoProblem.setType( "type" );
+ repoProblem.setVersion( "version" );
+
+ return repoProblem;
+ }
+
+ public void testArtifact()
+ throws Exception
+ {
+ artifactDao.saveArtifact( createArtifact( GROUP_ID_1 ) );
+ artifactDao.saveArtifact( createArtifact( GROUP_ID_2 ) );
+ artifactDao.saveArtifact( createArtifact( GROUP_ID_3 ) );
+
+ assertConstraint( 1, new UniqueFieldConstraint(
ArchivaArtifactModel.class.getName(), "artifactId" ) );
+ assertConstraint( 3, new UniqueFieldConstraint(
ArchivaArtifactModel.class.getName(), "groupId" ) );
+ }
+
+ public void testRepoProblem()
+ throws Exception
+ {
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1 )
);
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2 )
);
+ repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 )
);
+
+ assertConstraint( 1, new UniqueFieldConstraint(
RepositoryProblem.class.getName(), "artifactId" ) );
+ assertConstraint( 3, new UniqueFieldConstraint(
RepositoryProblem.class.getName(), "groupId" ) );
+ }
+
+ private void assertConstraint( int expectedHits, SimpleConstraint
constraint )
+ throws Exception
+ {
+ List results = archivaDao.query( constraint );
+ assertNotNull( "Repository Problems: Not Null", results );
+ assertEquals( "Repository Problems: Results.size", expectedHits,
results.size() );
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java?view=auto&rev=562511
==============================================================================
---
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
(added)
+++
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
Fri Aug 3 09:02:00 2007
@@ -0,0 +1,228 @@
+package org.apache.maven.archiva.web.action.reports;
+
+/*
+ * 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 com.opensymphony.webwork.interceptor.ServletRequestAware;
+import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.database.constraints.RangeConstraint;
+import
org.apache.maven.archiva.database.constraints.RepositoryProblemByGroupIdConstraint;
+import
org.apache.maven.archiva.database.constraints.RepositoryProblemByRepositoryIdConstraint;
+import
org.apache.maven.archiva.database.constraints.RepositoryProblemConstraint;
+import org.apache.maven.archiva.model.RepositoryProblem;
+import org.apache.maven.archiva.model.RepositoryProblemReport;
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
+import org.codehaus.plexus.xwork.action.PlexusActionSupport;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @plexus.component role="com.opensymphony.xwork.Action"
role-hint="generateReportAction"
+ */
+public class GenerateReportAction
+ extends PlexusActionSupport
+ implements SecureAction, ServletRequestAware
+{
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ protected ArchivaDAO dao;
+
+ protected Constraint constraint;
+
+ protected HttpServletRequest request;
+
+ protected List reports = new ArrayList();
+
+ protected String groupId;
+
+ protected String repositoryId;
+
+ protected String prev;
+
+ protected String next;
+
+ protected int[] range = new int[2];
+
+ protected int page = 1;
+
+ protected int rowCount = 100;
+
+ protected boolean isLastPage = false;
+
+ public static final String BLANK = "blank";
+
+ public String execute()
+ throws Exception
+ {
+ List problemArtifacts =
dao.getRepositoryProblemDAO().queryRepositoryProblems( configureConstraint() );
+
+ String contextPath =
+ request.getRequestURL().substring( 0,
request.getRequestURL().indexOf( request.getRequestURI() ) );
+ RepositoryProblem problemArtifact;
+ RepositoryProblemReport problemArtifactReport;
+ for ( int i = 0; i < problemArtifacts.size(); i++ )
+ {
+ problemArtifact = (RepositoryProblem) problemArtifacts.get( i );
+ problemArtifactReport = new RepositoryProblemReport(
problemArtifact );
+
+ problemArtifactReport.setGroupURL( contextPath + "/browse/" +
problemArtifact.getGroupId() );
+ problemArtifactReport.setArtifactURL(
+ contextPath + "/browse/" + problemArtifact.getGroupId() + "/"
+ problemArtifact.getArtifactId() );
+
+ reports.add( problemArtifactReport );
+ }
+
+ if ( reports.size() <= rowCount )
+ {
+ isLastPage = true;
+ }
+ else
+ {
+ reports.remove( rowCount );
+ }
+
+ prev = request.getRequestURL() + "?page=" + ( page - 1 ) +
"&rowCount=" + rowCount + "&groupId=" + groupId +
+ "&repositoryId=" + repositoryId;
+ next = request.getRequestURL() + "?page=" + ( page + 1 ) +
"&rowCount=" + rowCount + "&groupId=" + groupId +
+ "&repositoryId=" + repositoryId;
+
+ if ( reports.size() == 0 && page == 1 )
+ {
+ return BLANK;
+ }
+ else
+ {
+ return SUCCESS;
+ }
+ }
+
+ private Constraint configureConstraint()
+ {
+ Constraint constraint;
+
+ range[0] = ( page - 1 ) * rowCount;
+ range[1] = ( page * rowCount ) + 1; // Add 1 to check if it's the last
page or not.
+
+ if ( groupId != null && ( !groupId.equals( "" ) ) )
+ {
+ if ( repositoryId != null && ( !repositoryId.equals( "" ) ) )
+ {
+ constraint = new RepositoryProblemConstraint( range, groupId,
repositoryId );
+ }
+ else
+ {
+ constraint = new RepositoryProblemByGroupIdConstraint( range,
groupId );
+ }
+ }
+ else if ( repositoryId != null && ( !repositoryId.equals( "" ) ) )
+ {
+ constraint = new RepositoryProblemByRepositoryIdConstraint( range,
repositoryId );
+ }
+ else
+ {
+ constraint = new RangeConstraint( range );
+ }
+
+ return constraint;
+ }
+
+ public void setServletRequest( HttpServletRequest request )
+ {
+ this.request = request;
+ }
+
+ public List getReports()
+ {
+ return reports;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
+
+ public void setRepositoryId( String repositoryId )
+ {
+ this.repositoryId = repositoryId;
+ }
+
+ public String getPrev()
+ {
+ return prev;
+ }
+
+ public String getNext()
+ {
+ return next;
+ }
+
+ public int getPage()
+ {
+ return page;
+ }
+
+ public void setPage( int page )
+ {
+ this.page = page;
+ }
+
+ public int getRowCount()
+ {
+ return rowCount;
+ }
+
+ public void setRowCount( int rowCount )
+ {
+ this.rowCount = rowCount;
+ }
+
+ public boolean getIsLastPage()
+ {
+ return isLastPage;
+ }
+
+ public SecureActionBundle getSecureActionBundle()
+ throws SecureActionException
+ {
+ SecureActionBundle bundle = new SecureActionBundle();
+
+ bundle.setRequiresAuthentication( true );
+ bundle.addRequiredAuthorization(
ArchivaRoleConstants.OPERATION_ACCESS_REPORT, Resource.GLOBAL );
+
+ return bundle;
+ }
+}
Propchange:
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml?view=diff&rev=562511&r1=562510&r2=562511
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml
(original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml
Fri Aug 3 09:02:00 2007
@@ -395,34 +395,7 @@
<result>/WEB-INF/jsp/reports/showReports.jsp</result>
</action>
- <action name="allProblematicArtifacts"
class="allProblematicArtifactsAction">
- <result name="success" type="jasper">
- <param name="location">/WEB-INF/jasperreports/report.jasper</param>
- <param name="dataSource">reports</param>
- <param name="format">HTML</param>
- </result>
- <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
- </action>
-
- <action name="byGroupId" class="reportsByGroupIdAction">
- <result name="success" type="jasper">
- <param name="location">/WEB-INF/jasperreports/report.jasper</param>
- <param name="dataSource">reports</param>
- <param name="format">HTML</param>
- </result>
- <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
- </action>
-
- <action name="byArtifactId" class="reportsByArtifactIdAction">
- <result name="success" type="jasper">
- <param name="location">/WEB-INF/jasperreports/report.jasper</param>
- <param name="dataSource">reports</param>
- <param name="format">HTML</param>
- </result>
- <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
- </action>
-
- <action name="byRepositoryId" class="reportsByRepositoryIdAction">
+ <action name="generateReportAction" class="generateReportAction">
<result name="success" type="jasper">
<param name="location">/WEB-INF/jasperreports/report.jasper</param>
<param name="dataSource">reports</param>
Propchange:
maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Aug 3 09:02:00 2007
@@ -1,7 +1,7 @@
lib
+jasperreports
log
template
classes
database
logs
-jasperreports