[MRM-1025] remove model fields that are not used for clarity

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@886101 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2009-12-02 10:23:42 +00:00
parent 42122ac3df
commit 209df33fed
10 changed files with 20 additions and 291 deletions

View File

@ -19,6 +19,11 @@ package org.apache.maven.archiva.consumers.database;
* under the License.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
@ -41,11 +46,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository.
*
@ -193,8 +193,6 @@ public class ArtifactUpdateDatabaseConsumer
artifact.getModel().setLastModified( new Date( artifactFile.lastModified() ) );
artifact.getModel().setSize( artifactFile.length() );
artifact.getModel().setOrigin( "FileSystem" );
artifact.getModel().setWhenProcessed( null );
// set this to when the artifact was first discovered in the repo
if ( artifact.getModel().getWhenGathered() == null )

View File

@ -70,7 +70,7 @@
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<configuration>
<version>1.2.1</version>
<version>1.3.0</version>
<packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/archiva-base.xml</model>

View File

@ -5,7 +5,10 @@
xsd.target-namespace="http://archiva.apache.org/model/1.2.0">
<id>archiva-base-model</id>
<name>ArchivaBaseModel</name>
<version>1.2.1</version>
<!-- Note that we've outright removed old model information instead of setting the finish version to be 1.2.1.
if for any reason this model needs to be retained for some other use (eg, migration), then those may need to be
restored. Otherwise, the previous archiva-model artifact can be used if necessary -->
<version>1.3.0</version>
<description>Archiva Model</description>
<defaults>
<default>
@ -220,47 +223,6 @@
The size of the artifact on disk.
</description>
</field>
<field stash.maxSize="16">
<name>platform</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
<description>
The platform of this artifact. (default: "java")
</description>
<defaultValue>java</defaultValue>
</field>
<field>
<name>whenIndexed</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>Date</type>
<required>false</required>
<description>
The timestamp when this artifact was indexed.
</description>
</field>
<field>
<name>whenProcessed</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>Date</type>
<required>false</required>
<description>
When this artifact's contents was processed.
</description>
</field>
<field>
<name>origin</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>false</required>
<description>
The origin of this artifact. (Filesystem, Proxy, Deploy)
</description>
</field>
<field>
<name>whenGathered</name>
<identifier>false</identifier>
@ -279,20 +241,6 @@
private static final long serialVersionUID = -6292417108113887384L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
/**
* Identify if this artifact's contents have been processed or not.
*
* @return true if the artifact's contents have been processed.
*/
public boolean isProcessed()
{
return !(whenProcessed == null);
}
]]></code>
</codeSegment>
</codeSegments>
</class>
@ -443,26 +391,6 @@
The size of the artifact on disk.
</description>
</field>
<field>
<name>whenIndexed</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>Date</type>
<required>false</required>
<description>
The timestamp when this artifact was indexed.
</description>
</field>
<field>
<name>origin</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>false</required>
<description>
The origin of this artifact. (Filesystem, Proxy, Deploy)
</description>
</field>
</fields>
<codeSegments>
<codeSegment>

View File

@ -1,46 +0,0 @@
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.
*/
import java.util.Date;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
/**
* ArchivaModelClonerTest
*
* @version $Id: ArchivaModelClonerTest.java 525951 2007-04-05 20:11:19Z joakime $
*/
public class ArchivaArtifactTest
extends PlexusInSpringTestCase
{
public void testArtifactModelProcessed()
{
ArchivaArtifactModel model = new ArchivaArtifactModel();
assertNull( "whenProcessed", model.getWhenProcessed() );
assertFalse( "isProcessed", model.isProcessed() );
model.setWhenProcessed( new Date() );
assertTrue( "isProcessed", model.isProcessed() );
}
}

View File

@ -19,6 +19,9 @@ package org.apache.maven.archiva.repository.metadata;
* under the License.
*/
import java.io.File;
import java.util.Date;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
import org.apache.maven.archiva.model.Plugin;
@ -27,9 +30,6 @@ import org.apache.maven.archiva.xml.XMLException;
import org.apache.maven.archiva.xml.XMLReader;
import org.dom4j.Element;
import java.io.File;
import java.util.Date;
/**
* RepositoryMetadataReader - read maven-metadata.xml files.
*
@ -60,7 +60,6 @@ public class RepositoryMetadataReader
metadata.setVersion( xml.getElementText( "//metadata/version" ) );
metadata.setFileLastModified( new Date( metadataFile.lastModified() ) );
metadata.setFileSize( metadataFile.length() );
metadata.setWhenIndexed( null );
metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) );
metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) );

View File

@ -19,10 +19,10 @@ package org.apache.maven.archiva.database.constraints;
* under the License.
*/
import org.apache.maven.archiva.database.Constraint;
import java.util.Date;
import org.apache.maven.archiva.database.Constraint;
/**
* ArtifactsProcessedConstraint
*
@ -34,18 +34,6 @@ public class ArtifactsProcessedConstraint
{
private String whereClause;
public ArtifactsProcessedConstraint( boolean isProcessed )
{
if ( isProcessed )
{
whereClause = "whenProcessed != null";
}
else
{
whereClause = "whenProcessed == null";
}
}
/**
* A Constraint showing artifacts processed since date provided.
* @param since

View File

@ -34,7 +34,6 @@ public class AllTests
{
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.database.constraints" );
//$JUnit-BEGIN$
suite.addTestSuite( ArtifactsProcessedConstraintTest.class );
suite.addTestSuite( ArtifactsByChecksumConstraintTest.class );
suite.addTestSuite( OlderArtifactsByAgeConstraintTest.class );
suite.addTestSuite( UniqueGroupIdConstraintTest.class );

View File

@ -1,133 +0,0 @@
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 java.util.Date;
import java.util.List;
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.model.ArchivaArtifact;
/**
* ArtifactsProcessedConstraintTest
*
* @version $Id$
*/
public class ArtifactsProcessedConstraintTest
extends AbstractArchivaDatabaseTestCase
{
public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String whenProcessed )
throws Exception
{
ArchivaArtifact artifact = dao.getArtifactDAO().createArtifact( groupId, artifactId, version, "", "jar", "testrepo" );
assertNotNull( "Artifact should not be null.", artifact );
Date dateWhenProcessed = null;
if ( whenProcessed != null )
{
dateWhenProcessed = toDate( whenProcessed );
}
artifact.getModel().setWhenProcessed( dateWhenProcessed );
// Satisfy table / column requirements.
artifact.getModel().setLastModified( new Date() );
return artifact;
}
public void assertResults( String type, List<ArchivaArtifact> results, String expectedArtifacts[] )
{
assertNotNull( "Results[" + type + "] should not be null.", results );
assertEquals( "Results[" + type + "].size", expectedArtifacts.length, results.size() );
for ( int i = 0; i < expectedArtifacts.length; i++ )
{
String artifactId = expectedArtifacts[i];
int found = 0;
for ( ArchivaArtifact artifact : results )
{
if ( artifactId.equals( artifact.getArtifactId() ) )
{
found++;
}
}
if ( found <= 0 )
{
fail( "Results[" + type + "] - Did not find expected artifact ID [" + artifactId + "]" );
}
if ( found > 1 )
{
fail( "Results[" + type + "] - Expected to find 1 copy of artifact ID [" + artifactId
+ "], yet found <" + found + "> instead." );
}
}
}
@Override
protected void setUp()
throws Exception
{
super.setUp();
ArtifactDAO adao = dao.getArtifactDAO();
assertNotNull( "Artifact DAO should not be null.", adao );
adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-common", "1.0-SNAPSHOT", null ) );
adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-utils", "1.0-SNAPSHOT",
"2006/08/22 19:01:00" ) );
adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-old", "0.1", "2004/02/15 9:01:00" ) );
adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-database", "1.0-SNAPSHOT", null ) );
}
public void testNotProcessed()
throws Exception
{
List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) );
assertResults( "not-processed", results, new String[] { "archiva-common", "archiva-database" } );
}
public void testProcessed()
throws Exception
{
List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( true ) );
assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } );
}
public void testSinceRecent()
throws Exception
{
Date since = toDate( "2006/01/01 12:00:00" );
List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
assertResults( "processed", results, new String[] { "archiva-utils" } );
}
public void testSinceOld()
throws Exception
{
Date since = toDate( "2001/01/01 12:00:00" );
List<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } );
}
}

View File

@ -21,7 +21,6 @@ package org.apache.maven.archiva.database.jdo;
import java.util.Date;
import java.util.List;
import javax.jdo.JDOHelper;
import javax.jdo.spi.JDOImplHelper;
@ -67,7 +66,6 @@ public class JdoArtifactDAOTest
// Set some mandatory values
artifact.getModel().setLastModified( new Date() );
artifact.getModel().setOrigin( "test" );
// Save it.
ArchivaArtifact savedArtifact = artiDao.saveArtifact( artifact );
@ -90,7 +88,7 @@ public class JdoArtifactDAOTest
assertEquals( "jar", firstArtifact.getType() );
// Change value and save.
savedArtifact.getModel().setOrigin( "changed" );
savedArtifact.getModel().setLastModified( new Date() );
artiDao.saveArtifact( savedArtifact );
// Test that only 1 object is saved.
@ -103,7 +101,6 @@ public class JdoArtifactDAOTest
// Test expected values.
assertEquals( "archiva-test-module", actualArtifact.getArtifactId() );
assertEquals( "changed", actualArtifact.getModel().getOrigin() );
// Test that only 1 object is saved.
assertEquals( 1, artiDao.queryArtifacts( null ).size() );

View File

@ -32,7 +32,6 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.RepositoryContentStatistics;
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
@ -174,7 +173,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest
taskExecutor.executeTask( repoTask );
ArtifactDAO adao = dao.getArtifactDAO();
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
@ -215,7 +214,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest
taskExecutor.executeTask( repoTask );
ArtifactDAO adao = dao.getArtifactDAO();
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected. No new artifacts should have been found.", 0, unprocessedResultList.size() );
@ -232,7 +231,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest
taskExecutor.executeTask( repoTask );
unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1, unprocessedResultList.size() );
}
@ -272,7 +271,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest
taskExecutor.executeTask( repoTask );
ArtifactDAO adao = dao.getArtifactDAO();
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );