public class LuceneStandardIndexRecordConverter
implements LuceneIndexRecordConverter
{
public Document convert( RepositoryIndexRecord record )
{
StandardArtifactIndexRecord rec = (StandardArtifactIndexRecord) record;
Document document = new Document();
addTokenizedField( document, StandardIndexRecordFields.FILENAME, rec.getFilename() );
addTokenizedField( document, StandardIndexRecordFields.GROUPID, rec.getGroupId() );
addExactField( document, StandardIndexRecordFields.GROUPID_EXACT, rec.getGroupId() );
addTokenizedField( document, StandardIndexRecordFields.ARTIFACTID, rec.getArtifactId() );
addExactField( document, StandardIndexRecordFields.ARTIFACTID_EXACT, rec.getArtifactId() );
addTokenizedField( document, StandardIndexRecordFields.VERSION, rec.getVersion() );
addExactField( document, StandardIndexRecordFields.VERSION_EXACT, rec.getVersion() );
addTokenizedField( document, StandardIndexRecordFields.BASE_VERSION, rec.getBaseVersion() );
addExactField( document, StandardIndexRecordFields.BASE_VERSION_EXACT, rec.getBaseVersion() );
addUntokenizedField( document, StandardIndexRecordFields.TYPE, rec.getType() );
addTokenizedField( document, StandardIndexRecordFields.CLASSIFIER, rec.getClassifier() );
addUntokenizedField( document, StandardIndexRecordFields.PACKAGING, rec.getPackaging() );
addUntokenizedField( document, StandardIndexRecordFields.REPOSITORY, rec.getRepository() );
addUntokenizedField( document, StandardIndexRecordFields.LAST_MODIFIED,
DateTools.timeToString( rec.getLastModified(), DateTools.Resolution.SECOND ) );
addUntokenizedField( document, StandardIndexRecordFields.FILE_SIZE, NumberTools.longToString( rec.getSize() ) );
addUntokenizedField( document, StandardIndexRecordFields.MD5, rec.getMd5Checksum() );
addUntokenizedField( document, StandardIndexRecordFields.SHA1, rec.getSha1Checksum() );
if ( rec.getClasses() != null )
{
addTokenizedField( document, StandardIndexRecordFields.CLASSES,
StringUtils.join( rec.getClasses().iterator(), "\n" ) );
}
if ( rec.getFiles() != null )
{
addTokenizedField( document, StandardIndexRecordFields.FILES,
StringUtils.join( rec.getFiles().iterator(), "\n" ) );
}
addUntokenizedField( document, StandardIndexRecordFields.PLUGIN_PREFIX, rec.getPluginPrefix() );
addUntokenizedField( document, StandardIndexRecordFields.INCEPTION_YEAR, rec.getInceptionYear() );
addTokenizedField( document, StandardIndexRecordFields.PROJECT_NAME, rec.getProjectName() );
addTokenizedField( document, StandardIndexRecordFields.PROJECT_DESCRIPTION, rec.getProjectDescription() );
if ( rec.getDependencies() != null )
{
addTokenizedField( document, StandardIndexRecordFields.DEPENDENCIES,
StringUtils.join( rec.getDependencies().iterator(), "\n" ) );
}
if ( rec.getDevelopers() != null )
{
addTokenizedField( document, StandardIndexRecordFields.DEVELOPERS,
StringUtils.join( rec.getDevelopers().iterator(), "\n" ) );
}
/* TODO: add later
document.add( Field.Keyword( StandardIndexRecordFields.FLD_LICENSE_URLS, "" ) );
document.add( Field.Keyword( StandardIndexRecordFields.FLD_PLUGINS_REPORT, "" ) );
document.add( Field.Keyword( StandardIndexRecordFields.FLD_PLUGINS_BUILD, "" ) );