/** * Creates a new result with an updated score. * * @param origResult * Original result that contains an older score. * @param newScore * New score to update the result with. * @return Result with updated score. */ protected Result updateResult( Result origResult, float newScore ) { ResultImpl result = new ResultImpl( origResult.getMetacard() ); result.setRelevanceScore( (double) newScore ); result.setDistanceInMeters( origResult.getDistanceInMeters() ); return result; }
/** * Set an attribute via a name/value pair. * * @param name * the name of the {@link Attribute} * @param value * the value of the {@link Attribute} */ public void setAttribute( String name, Serializable value ) { setAttribute( new AttributeImpl( name, value ) ); }
stream.writeObject( type ); } else { MetacardTypeImpl mt = new MetacardTypeImpl( type.getName(), type.getAttributeDescriptors() ); stream.writeObject( mt );
@Override public Attribute getAttribute( String name ) { if ( Metacard.THUMBNAIL.equals( name ) ) { return new AttributeImpl( name, this.getThumbnail() ); } else if ( Metacard.METADATA.equals( name ) ) { return new AttributeImpl( name, this.getMetadata() ); } else { return (wrappedMetacard != null) ? wrappedMetacard.getAttribute( name ) : map.get( name ); } }
@Override public byte[] getThumbnail() { byte[] thumbnail = null; // We can't call getData here because it will get in an endless loop because of the explicit checks in // getAttribute (for THUMBNAIL), so instead we check the values ourselves then try to pull from the link (on // demand) Attribute thumbnailAttribute = (wrappedMetacard != null) ? wrappedMetacard.getAttribute( THUMBNAIL ) : map.get( THUMBNAIL ); if ( thumbnailAttribute == null || getAttributeValue( thumbnailAttribute, byte[].class ) == null ) { URI thumbnailURI = getThumbnailURL(); if ( thumbnailURI != null ) { try ( InputStream in = thumbnailURI.toURL().openStream() ) { thumbnail = IOUtils.toByteArray( in ); setAttribute( new AttributeImpl( Metacard.THUMBNAIL, thumbnail ) ); } catch ( MalformedURLException e ) { LOGGER.warn( "Cannot read thumbnail due to invalid thumbnail URL[" + thumbnailURI + "]: " + e.getMessage(), e ); } catch ( IOException e ) { LOGGER.warn( "Could not read thumbnail from remote URL[" + thumbnailURI + "] due to: " + e.getMessage(), e ); } } } else { thumbnail = getAttributeValue( thumbnailAttribute, byte[].class ); } return thumbnail; }
metadata = sb.toString(); setAttribute( new AttributeImpl( Metacard.METADATA, metadata ) ); } catch ( MalformedURLException e ) { LOGGER.warn( "Cannot read metadata due to Invalid metadata URL[" + metadataURI + "]: " + e.getMessage(), e );