project.setGroupId( groupId );
project.setVersion( version );
project.setArtifactType( artifactType );
project.setPublicKeyTokenId( publicKeyTokenId );
TupleQueryResult result = null;
try
{
TupleQuery tupleQuery = repositoryConnection.prepareTupleQuery( QueryLanguage.SERQL, projectQuery );
tupleQuery.setBinding( ProjectUri.GROUP_ID.getObjectBinding(), valueFactory.createLiteral( groupId ) );
tupleQuery.setBinding( ProjectUri.ARTIFACT_ID.getObjectBinding(), valueFactory.createLiteral( artifactId ) );
tupleQuery.setBinding( ProjectUri.VERSION.getObjectBinding(), valueFactory.createLiteral( version ) );
tupleQuery.setBinding( ProjectUri.ARTIFACT_TYPE.getObjectBinding(),
valueFactory.createLiteral( artifactType ) );
if ( publicKeyTokenId != null )
{
tupleQuery.setBinding( ProjectUri.CLASSIFIER.getObjectBinding(),
valueFactory.createLiteral( publicKeyTokenId ) );
project.setPublicKeyTokenId( publicKeyTokenId.replace( ":", "" ) );
}
result = tupleQuery.evaluate();
if ( !result.hasNext() )
{
//if ( artifactType != null && ArtifactTypeHelper.isDotnetAnyGac( artifactType ) )
if ( artifactType != null )
{
Artifact artifact = createArtifactFrom( project, artifactFactory );
if ( !artifact.getFile().exists() )
{
throw new ProjectDaoException( "NPANDAY-180-123: Could not find GAC assembly: Group ID = " + groupId
+ ", Artifact ID = " + artifactId + ", Version = " + version + ", Artifact Type = "
+ artifactType + ", File Path = " + artifact.getFile().getAbsolutePath() );
}
project.setResolved( true );
return project;
}
throw new ProjectDaoException( "NPANDAY-180-124: Could not find the project: Group ID = " + groupId
+ ", Artifact ID = " + artifactId + ", Version = " + version + ", Artifact Type = " + artifactType );
}
while ( result.hasNext() )
{
BindingSet set = result.next();
/*
* for ( Iterator<Binding> i = set.iterator(); i.hasNext(); ) { Binding b = i.next();
* System.out.println( b.getName() + ":" + b.getValue() ); }
*/
if ( set.hasBinding( ProjectUri.IS_RESOLVED.getObjectBinding() )
&& set.getBinding( ProjectUri.IS_RESOLVED.getObjectBinding() ).getValue().toString().equalsIgnoreCase(
"true" ) )
{
project.setResolved( true );
}
project.setArtifactType( set.getBinding( ProjectUri.ARTIFACT_TYPE.getObjectBinding() ).getValue().toString() );
/*
* if ( set.hasBinding( ProjectUri.PARENT.getObjectBinding() ) ) { String pid = set.getBinding(
* ProjectUri.PARENT.getObjectBinding() ).getValue().toString(); String[] tokens = pid.split( "[:]" );
* Project parentProject = getProjectFor( tokens[0], tokens[1], tokens[2], null, null );
* project.setParentProject( parentProject ); }
*/
if ( set.hasBinding( ProjectUri.DEPENDENCY.getObjectBinding() ) )
{
Binding binding = set.getBinding( ProjectUri.DEPENDENCY.getObjectBinding() );
addDependenciesToProject( project, repositoryConnection, binding.getValue() );
}
if ( set.hasBinding( ProjectUri.CLASSIFIER.getObjectBinding() ) )
{
Binding binding = set.getBinding( ProjectUri.CLASSIFIER.getObjectBinding() );
addClassifiersToProject( project, repositoryConnection, binding.getValue() );
}
}
}
catch ( QueryEvaluationException e )
{
throw new ProjectDaoException( "NPANDAY-180-005: Message = " + e.getMessage(), e );
}
catch ( RepositoryException e )
{
throw new ProjectDaoException( "NPANDAY-180-006: Message = " + e.getMessage(), e );
}
catch ( MalformedQueryException e )
{
throw new ProjectDaoException( "NPANDAY-180-007: Message = " + e.getMessage(), e );
}
finally
{
if ( result != null )
{
try
{
result.close();
}
catch ( QueryEvaluationException e )
{
}