/** * Returns the Maven artifact representing the correpsonding core jar file. */ public MavenArtifact getCoreArtifact() { return new MavenArtifact(repository,new ArtifactInfo( artifact.repository, artifact.groupId, artifact.artifactId.replace("war","core"), artifact.version, artifact.classifier )); }
n = -f1.getArtifactVersion().compareTo( f2.getArtifactVersion() ); if ( n != 0 )
protected String getMatchHighlightHtmlSnippet( ArtifactInfo ai ) { if ( ai.getMatchHighlights().size() > 0 ) { // <blockquote>Artifact classes // <ul> // <li>aaaa</li> // <li>bbbbb</li> // </ul> // </blockquote> StringBuilder sb = new StringBuilder(); for ( MatchHighlight mh : ai.getMatchHighlights() ) { sb.append( "<blockquote>" ).append( mh.getField().getDescription() ).append( "<UL>" ); // TODO: fix this! for ( String high : mh.getHighlightedMatch() ) { sb.append( "<LI>" ).append( high ).append( "</LI>" ); } sb.append( "</UL></blockquote>" ); } return sb.toString(); } else { return null; } }
public void postprocess( IndexingContext ctx, ArtifactInfo ai ) { for ( Field field : ai.getFields() ) { if ( !uniqueFields.contains( field ) ) { ai.setFieldValue( field, COLLAPSED ); } } }
ArtifactInfo ai = new ArtifactInfo(); ai.classifier = ArtifactInfo.renvl( ra[3] ); ai.packaging = ArtifactInfo.renvl( ra[4] ); ArtifactContext ac = new ArtifactContext( null, null, null, ai, ai.calculateGav() );
ArtifactInfo ai = new ArtifactInfo( null, gav.getGroupId(), gav.getClassifier() ); Term term = new Term( ArtifactInfo.UINFO, ai.getUinfo() );
public void remove( IndexingContext context, ArtifactContext ac ) throws IOException { if ( ac != null ) { String uinfo = ac.getArtifactInfo().getUinfo(); // add artifact deletion marker Document doc = new Document(); doc.add( new Field( ArtifactInfo.DELETED, uinfo, Field.Store.YES, Field.Index.NO ) ); doc.add( new Field( ArtifactInfo.LAST_MODIFIED, // Long.toString( System.currentTimeMillis() ), Field.Store.YES, Field.Index.NO ) ); IndexWriter w = context.getIndexWriter(); w.addDocument( doc ); w.deleteDocuments( new Term( ArtifactInfo.UINFO, uinfo ) ); w.commit(); context.updateTimestamp(); } }
text = ai.getFieldValue( field.getOntology() ); ai.getMatchHighlights().add( matchHighlight );
public void artifactDiscovered( ArtifactContext ac ) String uinfo = ac.getArtifactInfo().getUinfo(); groups.add( ac.getArtifactInfo().getRootGroup() ); allGroups.add( ac.getArtifactInfo().groupId );
private void updateGroups( IndexingContext context, ArtifactContext ac ) throws IOException { String rootGroup = ac.getArtifactInfo().getRootGroup(); Set<String> rootGroups = context.getRootGroups(); if ( !rootGroups.contains( rootGroup ) ) { rootGroups.add( rootGroup ); context.setRootGroups( rootGroups ); } Set<String> allGroups = context.getAllGroups(); if ( !allGroups.contains( ac.getArtifactInfo().groupId ) ) { allGroups.add( ac.getArtifactInfo().groupId ); context.setAllGroups( allGroups ); } }
public ArtifactContext( File pom, File artifact, File metadata, ArtifactInfo artifactInfo, Gav gav ) throws IllegalArtifactCoordinateException { if ( artifactInfo == null ) { throw new IllegalArtifactCoordinateException( "Parameter artifactInfo must not be null." ); } this.pom = pom; this.artifact = artifact; this.metadata = metadata; this.artifactInfo = artifactInfo; this.gav = gav == null ? artifactInfo.calculateGav() : gav; }
public boolean accepts( IndexingContext ctx, ArtifactInfo ai ) { StringBuilder sb = new StringBuilder(); for ( Field field : uniqueFields ) { sb.append( ai.getFieldValue( field ) ).append( ":" ); } String key = sb.toString().substring( 0, sb.length() - 1 ); if ( gas.contains( key ) ) { return false; } else { gas.add( key ); postprocess( ctx, ai ); return true; } }
&& ( firstDocumentScore - ai.getLuceneScore() ) > DOCUMENT_TOP_RELEVANCE_HIT_CHANGE_THRESHOLD ) + firstDocumentScore + ", currentDocScore=" + ai.getLuceneScore() + ")." ); if ( ( lastDocumentScore - ai.getLuceneScore() ) > DOCUMENT_RELEVANCE_HIT_CHANGE_THRESHOLD ) + ", currentDocScore=" + ai.getLuceneScore() + ")." ); firstDocumentScore = ai.getLuceneScore(); lastDocumentScore = ai.getLuceneScore();
static Document updateLegacyDocument( Document doc, IndexingContext context ) { ArtifactInfo ai = IndexUtils.constructArtifactInfo( doc, context ); if ( ai == null ) { return doc; } Document document = new Document(); document.add( new Field( ArtifactInfo.UINFO, ai.getUinfo(), Field.Store.YES, Field.Index.UN_TOKENIZED ) ); for ( IndexCreator ic : context.getIndexCreators() ) { if ( ic instanceof LegacyDocumentUpdater ) { ( (LegacyDocumentUpdater) ic ).updateLegacyDocument( ai, document ); } } return document; }
/** * Used to rebuild group information, for example on context which were merged, since merge() of contexts * only merges the Documents with UINFO record (Artifacts). */ public static void rebuildGroups( IndexingContext context ) throws IOException { IndexReader r = context.getIndexReader(); Set<String> rootGroups = new LinkedHashSet<String>(); Set<String> allGroups = new LinkedHashSet<String>(); int numDocs = r.maxDoc(); for ( int i = 0; i < numDocs; i++ ) { if ( r.isDeleted( i ) ) { continue; } Document d = r.document( i ); String uinfo = d.get( ArtifactInfo.UINFO ); if ( uinfo != null ) { ArtifactInfo info = IndexUtils.constructArtifactInfo( d, context ); rootGroups.add( info.getRootGroup() ); allGroups.add( info.groupId ); } } setRootGroups( context, rootGroups ); setAllGroups( context, allGroups ); context.optimize(); }
public static ArtifactInfo constructArtifactInfo( Document doc, IndexingContext context ) { // if no UINFO can't create, must be a different type of record if ( doc.get( ArtifactInfo.UINFO ) == null ) { return null; } boolean res = false; ArtifactInfo artifactInfo = new ArtifactInfo(); for ( IndexCreator ic : context.getIndexCreators() ) { res |= ic.updateArtifactInfo( doc, artifactInfo ); } return res ? artifactInfo : null; }
document.add( new Field( ArtifactInfo.UINFO, ai.getUinfo(), Field.Store.YES, Field.Index.UN_TOKENIZED ) );
ArtifactVersion version = ai.getArtifactVersion();
try { File parentPomFile = latest.repository.resolve( new ArtifactInfo("", parent.element("groupId").getTextTrim(), parent.element("artifactId").getTextTrim(),
doc.add( new Field( ArtifactInfo.UINFO, getArtifactInfo().getUinfo(), Store.YES, Index.UN_TOKENIZED ) );