<description>
The snapshot version id.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>SnapshotVersion</type>
<multiplicity>1</multiplicity>
</association>
-->
<class stash.storable="true"
- jpox.table="PROJECT_REFERENCE"
- jpox.use-identifiers-as-primary-key="false"
- jpox.identity-type="application"
- jpox.identity-class="org.apache.maven.archiva.model.jpox.ProjectReferenceKey">
+ jpox.table="PROJECT_REFERENCE">
<name>ProjectReference</name>
<description>A reference to another (unversioned) Project</description>
<version>1.0.0+</version>
<fields>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>groupId</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
<description>
- The Group ID of the repository content.
+ The Group ID of the project reference.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>artifactId</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
<description>
- The Artifact ID of the repository content.
+ The Artifact ID of the project reference.
</description>
</field>
</fields>
private static final long serialVersionUID = 8947981859537138991L;
]]></code>
</codeSegment>
+ <codeSegment>
+ <version>1.0.0+</version>
+ <code><![CDATA[
+ private static String defaultString( String value )
+ {
+ if ( value == null )
+ {
+ return "";
+ }
+
+ return value.trim();
+ }
+
+ public static String toKey( ProjectReference reference )
+ {
+ StringBuffer key = new StringBuffer();
+
+ key.append( defaultString( reference.getGroupId() ) ).append( ":" );
+ key.append( defaultString( reference.getArtifactId() ) ).append( ":" );
+
+ return key.toString();
+ }
+ ]]></code>
+ </codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
- jpox.table="VERSIONED_REFERENCE"
- jpox.use-identifiers-as-primary-key="false"
- jpox.identity-type="application"
- jpox.identity-class="org.apache.maven.archiva.model.jpox.VersionedReferenceKey">
+ jpox.table="VERSIONED_REFERENCE">
<name>VersionedReference</name>
<description>A reference to another Versioned Project</description>
<version>1.0.0+</version>
<fields>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>groupId</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
The Group ID of the repository content.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>artifactId</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
The Artifact ID of the repository content.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>version</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>false</required>
private static final long serialVersionUID = -6990353165677563113L;
]]></code>
</codeSegment>
+ <codeSegment>
+ <version>1.0.0+</version>
+ <code><![CDATA[
+ private static String defaultString( String value )
+ {
+ if ( value == null )
+ {
+ return "";
+ }
+
+ return value.trim();
+ }
+
+ public static String toKey( VersionedReference reference )
+ {
+ StringBuffer key = new StringBuffer();
+
+ key.append( defaultString( reference.getGroupId() ) ).append( ":" );
+ key.append( defaultString( reference.getArtifactId() ) ).append( ":" );
+ key.append( defaultString( reference.getVersion() ) ).append( ":" );
+
+ return key.toString();
+ }
+ ]]></code>
+ </codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
- jpox.table="ARTIFACT_REFERENCE"
- jpox.use-identifiers-as-primary-key="false"
- jpox.identity-type="application"
- jpox.identity-class="org.apache.maven.archiva.model.jpox.ArtifactReferenceKey">
+ jpox.table="ARTIFACT_REFERENCE">
<name>ArtifactReference</name>
<version>1.0.0+</version>
<fields>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>groupId</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
The Group ID of the repository content.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>artifactId</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
The Artifact ID of the repository content.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>version</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>false</required>
The version of the repository content.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent">
+ <field null-value="default">
<name>classifier</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
The classifier for this artifact.
</description>
</field>
- <field jpox.primary-key="true"
- jpox.value-strategy="off"
- jpox.persistence-modifier="persistent"
+ <field null-value="default"
jpox.column="FILE_TYPE">
<name>type</name>
- <identifier>true</identifier>
+ <identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<required>true</required>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
+ private static String defaultString( String value )
+ {
+ if ( value == null )
+ {
+ return "";
+ }
+
+ return value.trim();
+ }
+
public static String toKey( ArtifactReference artifactReference )
{
StringBuffer key = new StringBuffer();
- key.append( artifactReference.getGroupId() ).append( ":" );
- key.append( artifactReference.getArtifactId() ).append( ":" );
- key.append( artifactReference.getVersion() ).append( ":" );
- if ( artifactReference.getClassifier() != null )
- {
- key.append( artifactReference.getClassifier() );
- }
- key.append( ":" );
- key.append( artifactReference.getType() );
+ key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getVersion() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getClassifier() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getType() ) );
return key.toString();
}
{
StringBuffer key = new StringBuffer();
- key.append( artifactReference.getGroupId() ).append( ":" );
- key.append( artifactReference.getArtifactId() ).append( ":" );
- if ( artifactReference.getClassifier() != null )
- {
- key.append( artifactReference.getClassifier() );
- }
- key.append( ":" );
- key.append( artifactReference.getType() );
+ key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getClassifier() ) ).append( ":" );
+ key.append( defaultString( artifactReference.getType() ) );
return key.toString();
}
<identifier>false</identifier>
<version>1.0.0+</version>
<required>false</required>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>VersionedReference</type>
<multiplicity>1</multiplicity>
</association>
<identifier>false</identifier>
<version>1.0.0+</version>
<required>false</required>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>Organization</type>
</association>
</field>
<identifier>false</identifier>
<version>1.0.0+</version>
<required>false</required>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>License</type>
<multiplicity>*</multiplicity>
</association>
<version>1.0.0+</version>
<description>The mailing lists.</description>
<required>false</required>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>MailingList</type>
<multiplicity>*</multiplicity>
</association>
<name>issueManagement</name>
<version>1.0.0+</version>
<description><![CDATA[The project's issue management system information.]]></description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>IssueManagement</type>
</association>
</field>
<name>ciManagement</name>
<version>1.0.0+</version>
<description><![CDATA[The project's continuous integration information.]]></description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>CiManagement</type>
</association>
</field>
<version>1.0.0+</version>
<description>
<![CDATA[Specification for the SCM used by the project, such as CVS, Subversion, etc.]]></description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>Scm</type>
</association>
</field>
<description>
The list of individuals around this project.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>Individual</type>
<multiplicity>*</multiplicity>
</association>
This element describes all of the dependencies associated with a
project.
]]></description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>Dependency</type>
<multiplicity>*</multiplicity>
</association>
<description>
The list of dependency management settings.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>Dependency</type>
<multiplicity>*</multiplicity>
</association>
<description>
The list project repositories in use by this project.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>ProjectRepository</type>
<multiplicity>*</multiplicity>
</association>
<description>
The list of plugins that this project uses.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>ArtifactReference</type>
<multiplicity>*</multiplicity>
</association>
<description>
The list of reports that this project uses.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>ArtifactReference</type>
<multiplicity>*</multiplicity>
</association>
<description>
The list of build extensions that this project uses.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>ArtifactReference</type>
<multiplicity>*</multiplicity>
</association>
Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to
calculating transitive dependencies.
</description>
- <association>
+ <association stash.part="true"
+ jpox.join="false">
<type>Exclusion</type>
<multiplicity>*</multiplicity>
</association>
model.setReports( getReports( xml ) );
model.setProperties( getProperties( xml.getElement( "//project/properties" ) ) );
+ model.setBuildExtensions( getBuildExtensions( xml ) );
+
return model;
}
catch ( XMLException e )
return reference;
}
+ /**
+ * Get List of {@link ArtifactReference} objects from xpath expr.
+ */
+ private List getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType )
+ throws XMLException
+ {
+ List plugins = new ArrayList();
+
+ Iterator it = xml.getElementList( xpathExpr ).iterator();
+ while ( it.hasNext() )
+ {
+ Element elemPlugin = (Element) it.next();
+
+ plugins.add( getArtifactReference( elemPlugin, defaultType ) );
+ }
+
+ return plugins;
+ }
+
+ private List getBuildExtensions( XMLReader xml )
+ throws XMLException
+ {
+ return getArtifactReferenceList( xml, "//project/build/extensions/extension", "jar" );
+ }
+
private CiManagement getCiManagement( XMLReader xml )
throws XMLException
{
return null;
}
+ private List getLicenses( XMLReader xml )
+ throws XMLException
+ {
+ List licenses = new ArrayList();
+
+ Element elemLicenses = xml.getElement( "//project/licenses" );
+
+ if ( elemLicenses != null )
+ {
+ Iterator itLicense = elemLicenses.elements( "license" ).iterator();
+ while ( itLicense.hasNext() )
+ {
+ Element elemLicense = (Element) itLicense.next();
+ License license = new License();
+
+ // TODO: Create LicenseIdentity class to managed license ids.
+ // license.setId( elemLicense.elementTextTrim("id") );
+ license.setName( elemLicense.elementTextTrim( "name" ) );
+ license.setUrl( elemLicense.elementTextTrim( "url" ) );
+ license.setComments( elemLicense.elementTextTrim( "comments" ) );
+
+ licenses.add( license );
+ }
+ }
+
+ return licenses;
+ }
+
private List getMailingLists( XMLReader xml )
throws XMLException
{
return mailingLists;
}
- private List getLicenses( XMLReader xml )
- throws XMLException
- {
- List licenses = new ArrayList();
-
- Element elemLicenses = xml.getElement( "//project/licenses" );
-
- if ( elemLicenses != null )
- {
- Iterator itLicense = elemLicenses.elements( "license" ).iterator();
- while ( itLicense.hasNext() )
- {
- Element elemLicense = (Element) itLicense.next();
- License license = new License();
-
- // TODO: Create LicenseIdentity class to managed license ids.
- // license.setId( elemLicense.elementTextTrim("id") );
- license.setName( elemLicense.elementTextTrim( "name" ) );
- license.setUrl( elemLicense.elementTextTrim( "url" ) );
- license.setComments( elemLicense.elementTextTrim( "comments" ) );
-
- licenses.add( license );
- }
- }
-
- return licenses;
- }
-
private Organization getOrganization( XMLReader xml )
throws XMLException
{
private List getPlugins( XMLReader xml )
throws XMLException
{
- return getPlugins( xml, "//project/build/plugins/plugin" );
- }
-
- /**
- * Get List of {@link RepositoryContent} objects from plugin definitions.
- */
- private List getPlugins( XMLReader xml, String xpathExpr )
- throws XMLException
- {
- List plugins = new ArrayList();
-
- Iterator it = xml.getElementList( xpathExpr ).iterator();
- while ( it.hasNext() )
- {
- Element elemPlugin = (Element) it.next();
-
- plugins.add( getArtifactReference( elemPlugin, "maven-plugin" ) );
- }
-
- return plugins;
+ return getArtifactReferenceList( xml, "//project/build/plugins/plugin", "maven-plugin" );
}
private Properties getProperties( Element elemProperties )
private List getReports( XMLReader xml )
throws XMLException
{
- return getPlugins( xml, "//project/reporting/plugins/plugin" );
+ return getArtifactReferenceList( xml, "//project/reporting/plugins/plugin", "maven-plugin" );
}
private List getRepositories( XMLReader xml )
* under the License.
*/
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.database.ProjectModelDAO;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.repository.project.ProjectModelReader;
import java.io.File;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import javax.jdo.JDOHelper;
assertEquals( 0, projectDao.queryProjectModels( null ).size() );
}
- public void disabled_testSaveGetRealProjectModel()
+ public void testSaveGetRealProjectModel()
throws Exception
{
String groupId = "org.apache.maven.shared";
ArchivaProjectModel model = modelReader.read( pomFile );
assertNotNull( "Model should not be null.", model );
- // Fill in missing (mandatory) fields
+ /* NOTE: We are intentionally using a basic project model in this unit test.
+ * The expansion of expressions, resolving of dependencies, and merging
+ * of parent poms is *NOT* performed to keep this unit test simple.
+ */
+
+ // Fill in mandatory/missing fields
model.setGroupId( groupId );
model.setOrigin( "testcase" );
assertNotNull( "Project model should not be null.", savedModel );
// Test proper detachment of sub-objects.
- assertNotNull( "model.parent != null", savedModel.getParentProject() );
+ List exprs = new ArrayList();
+ exprs.add( "parentProject.groupId" );
+ exprs.add( "organization.name" );
+ exprs.add( "issueManagement.system" );
+ exprs.add( "ciManagement.system" );
+ exprs.add( "scm.url" );
+ exprs.add( "individuals[0].name" );
+ exprs.add( "dependencies[0].groupId" );
+ exprs.add( "dependencyManagement[0].artifactId" );
+ exprs.add( "repositories[0].id" );
+ exprs.add( "plugins[0].artifactId" );
+ exprs.add( "reports[0].artifactId" );
+ exprs.add( "buildExtensions[0].artifactId" );
+ exprs.add( "licenses[0].url" );
+ exprs.add( "mailingLists[0].name" );
+
+ Iterator it = exprs.iterator();
+ while ( it.hasNext() )
+ {
+ String expr = (String) it.next();
+ try
+ {
+ Object obj = PropertyUtils.getProperty( model, expr );
+ assertNotNull( "Expr \"" + expr + "\" != null", obj );
+ assertTrue( "Expr \"" + expr + "\" should be a String.", ( obj instanceof String ) );
+ String value = (String) obj;
+ assertTrue( "Expr \"" + expr + "\" value should not be blank.", StringUtils.isNotBlank( value ) );
+ }
+ catch ( IndexOutOfBoundsException e )
+ {
+ fail( "Expr \"" + expr + "\" unable to get indexed property: " + e.getClass().getName() + ": "
+ + e.getMessage() );
+ }
+ }
}
}