CPD Results
The following document contains the results of PMD's CPD 6.13.0.
Duplications
File |
Line |
fr/paris/lutece/plugins/announce/service/announcesearch/AnnounceLuceneSearchEngine.java |
87 |
fr/paris/lutece/plugins/announce/service/announcesearch/AnnounceLuceneSearchEngine.java |
225 |
int nNbResults = 0;
try
{
searcher = AnnounceSearchService.getInstance( ).getSearcher( );
Collection<String> queries = new ArrayList<>( );
Collection<String> sectors = new ArrayList<>( );
Collection<BooleanClause.Occur> flags = new ArrayList<>( );
// Category id
if ( filter.getIdCategory( ) != NO_CATEGORY )
{
Query queryCategoryId = new TermQuery( new Term( AnnounceSearchItem.FIELD_CATEGORY_ID, String.valueOf( filter.getIdCategory( ) ) ) );
queries.add( queryCategoryId.toString( ) );
sectors.add( AnnounceSearchItem.FIELD_CATEGORY_ID );
flags.add( BooleanClause.Occur.MUST );
}
// Category id
if ( filter.getIdSector( ) != NO_SECTOR )
{
Query querySectorId = new TermQuery( new Term( AnnounceSearchItem.FIELD_SECTOR_ID, String.valueOf( filter.getIdSector( ) ) ) );
queries.add( querySectorId.toString( ) );
sectors.add( AnnounceSearchItem.FIELD_SECTOR_ID );
flags.add( BooleanClause.Occur.MUST );
}
// Type (=announce)
PhraseQuery.Builder queryTypeBuilder = new PhraseQuery.Builder( );
// add character "e" to TYPE because field is not analyzed when added to lucene document, but it's analyzed then in MultiFieldQueryParser.parse
// method
queryTypeBuilder.add( new Term( SearchItem.FIELD_TYPE, AnnouncePlugin.PLUGIN_NAME + "e" ) );
queries.add( queryTypeBuilder.build( ).toString( ) );
sectors.add( SearchItem.FIELD_TYPE );
flags.add( BooleanClause.Occur.MUST );
// Keywords in title or description
if ( StringUtils.isNotBlank( filter.getKeywords( ) ) )
{
PhraseQuery.Builder queryContentBuilder = new PhraseQuery.Builder( );
queryContentBuilder.add( new Term( SearchItem.FIELD_CONTENTS, filter.getKeywords( ) ) );
queries.add( queryContentBuilder.build( ).toString( ) );
sectors.add( SearchItem.FIELD_CONTENTS );
flags.add( BooleanClause.Occur.MUST );
}
// contains range date
if ( ( filter.getDateMin( ) != null ) || ( filter.getDateMax( ) != null ) )
{ |
File |
Line |
fr/paris/lutece/plugins/announce/service/announcesearch/AnnounceLuceneSearchEngine.java |
145 |
fr/paris/lutece/plugins/announce/service/announcesearch/AnnounceLuceneSearchEngine.java |
288 |
{
dateMaxToSearch = filter.getDateMax( );
}
// String stringDateMin = DateUtil.
String strLowerTerm = _dayFormat.format( dateMinToSearch );
String strUpperTerm = _dayFormat.format( dateMaxToSearch );
BytesRef bRLowerTerm = new BytesRef( strLowerTerm );
BytesRef bRUpperTerm = new BytesRef( strUpperTerm );
Query queryRangeDate = new TermRangeQuery( SearchItem.FIELD_DATE, bRLowerTerm, bRUpperTerm, true, true );
queries.add( queryRangeDate.toString( ) );
sectors.add( SearchItem.FIELD_DATE );
flags.add( BooleanClause.Occur.MUST );
}
// contains range price
if ( ( filter.getPriceMin( ) > 0 ) || ( filter.getPriceMax( ) > 0 ) )
{
int nPriceMin = ( filter.getPriceMin( ) > 0 ) ? filter.getPriceMin( ) : 0;
int nPriceMax = ( filter.getPriceMax( ) > 0 ) ? filter.getPriceMax( ) : Integer.MAX_VALUE;
Query queryRangePrice = new TermRangeQuery( AnnounceSearchItem.FIELD_PRICE,
new BytesRef( AnnounceSearchService.formatPriceForIndexer( nPriceMin ) ),
new BytesRef( AnnounceSearchService.formatPriceForIndexer( nPriceMax ) ), true, true );
queries.add( queryRangePrice.toString( ) );
sectors.add( AnnounceSearchItem.FIELD_PRICE );
flags.add( BooleanClause.Occur.MUST );
}
Query queryMulti = MultiFieldQueryParser.parse( queries.toArray( new String [ queries.size( )] ), sectors.toArray( new String [ sectors.size( )] ),
flags.toArray( new BooleanClause.Occur [ flags.size( )] ), AnnounceSearchService.getInstance( ).getAnalyzer( ) );
TopDocs topDocs = searcher.search( queryMulti, 1000000 );
ScoreDoc [ ] hits = topDocs.scoreDocs;
nNbResults = hits.length; |
File |
Line |
fr/paris/lutece/plugins/announce/service/AnnounceSubscriptionProvider.java |
128 |
fr/paris/lutece/plugins/announce/service/AnnounceSubscriptionProvider.java |
189 |
model.put( MARK_USER, subscribedUser );
HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_USER_SUBSCRIPTION_DESCRIPTION, locale, model );
return template.getHtml( );
}
else
if ( StringUtils.equals( SUBSCRIPTION_CATEGORY, strSubscriptionKey ) )
{
Map<String, Object> model = new HashMap<>( );
int nIdCategory = Integer.parseInt( strIdSubscribedResource );
model.put( MARK_CATEGORY, CategoryHome.findByPrimaryKey( nIdCategory ) );
HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CATEGORY_SUBSCRIPTION_DESCRIPTION, locale, model );
return template.getHtml( );
}
else
if ( StringUtils.equals( SUBSCRIPTION_FILTER, strSubscriptionKey ) )
{
AnnounceSearchFilter filter = AnnounceSearchFilterHome.findByPrimaryKey( Integer.parseInt( strIdSubscribedResource ) );
Map<String, Object> model = new HashMap<>( );
model.put( MARK_FILTER, filter );
if ( filter.getIdCategory( ) > 0 )
{
model.put( MARK_CATEGORY, CategoryHome.findByPrimaryKey( filter.getIdCategory( ) ) );
}
HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_FILTER_SUBSCRIPTION_DESCRIPTION, locale, model );
return template.getHtml( );
}
return StringUtils.EMPTY;
}
/**
* {@inheritDoc}
*/
@Override
public String getSubscriptionHtmlDescriptionBis( LuteceUser user, String strSubscriptionKey, String strIdSubscribedResource, Locale locale, String userSub ) |
File |
Line |
fr/paris/lutece/plugins/announce/web/AnnounceApp.java |
1077 |
fr/paris/lutece/plugins/announce/web/AnnounceApp.java |
1205 |
EntryFilter filter = new EntryFilter( );
filter.setIdResource( category.getId( ) );
filter.setResourceType( Category.RESOURCE_TYPE );
filter.setEntryParentNull( EntryFilter.FILTER_TRUE );
filter.setFieldDependNull( EntryFilter.FILTER_TRUE );
filter.setIdIsComment( EntryFilter.FILTER_FALSE );
List<Entry> listEntryFirstLevel = EntryHome.getEntryList( filter );
List<GenericAttributeError> listErrors = new ArrayList<>( );
AnnounceDTO announceDTO = new AnnounceDTO( announce );
for ( Entry entry : listEntryFirstLevel )
{
listErrors.addAll( _announceService.getResponseEntry( request, entry.getIdEntry( ), request.getLocale( ), announceDTO ) );
}
if ( category.getDisplayCaptcha( ) && _captchaSecurityService.isAvailable( ) && !_captchaSecurityService.validate( request ) )
{
GenericAttributeError genAttError = new GenericAttributeError( );
genAttError.setErrorMessage( I18nService.getLocalizedString( ERROR_MESSAGE_WRONG_CAPTCHA, request.getLocale( ) ) );
listErrors.add( genAttError );
} |
File |
Line |
fr/paris/lutece/plugins/announce/web/AnnounceApp.java |
710 |
fr/paris/lutece/plugins/announce/web/AnnounceJspBean.java |
249 |
Collection<Entry> listGeolocalisation = new ArrayList<>( );
for ( Response response : listResponses )
{
if ( response.getEntry( ) != null && response.getEntry( ).getEntryType( ) != null
&& "announce.entryTypeGeolocation".equals( response.getEntry( ).getEntryType( ).getBeanName( ) ) )
{
Entry entry = EntryHome.findByPrimaryKey( response.getEntry( ).getIdEntry( ) );
for ( Field filed : entry.getFields( ) )
{
if ( response.getField( ) != null && filed.getIdField( ) == response.getField( ).getIdField( ) )
{
response.setField( filed );
}
}
boolean bool = true;
for ( Entry ent : listGeolocalisation )
{
if ( ent.getIdEntry( ) == ( entry.getIdEntry( ) ) )
{
bool = false;
}
}
if ( bool )
{
listGeolocalisation.add( entry );
}
}
} |
File |
Line |
fr/paris/lutece/plugins/announce/business/CategoryDAO.java |
86 |
fr/paris/lutece/plugins/announce/business/CategoryDAO.java |
107 |
public void insert( Category category, Plugin plugin )
{
try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, plugin ) )
{
category.setId( newPrimaryKey( plugin ) );
int nIndex = 1;
daoUtil.setInt( nIndex++, category.getId( ) );
daoUtil.setInt( nIndex++, category.getIdSector( ) );
daoUtil.setString( nIndex++, category.getLabel( ) );
daoUtil.setBoolean( nIndex++, category.getDisplayPrice( ) );
daoUtil.setBoolean( nIndex++, category.getPriceMandatory( ) );
daoUtil.setInt( nIndex++, category.getAnnouncesValidation( ) );
daoUtil.setInt( nIndex++, category.getIdMailingList( ) );
daoUtil.setBoolean( nIndex++, category.getDisplayCaptcha( ) );
daoUtil.setInt( nIndex, category.getIdWorkflow( ) );
daoUtil.executeUpdate( );
} |
File |
Line |
fr/paris/lutece/plugins/announce/web/AnnounceApp.java |
1034 |
fr/paris/lutece/plugins/announce/web/AnnounceApp.java |
1163 |
String strTitleAnnounce = request.getParameter( PARAMETER_TITLE_ANNOUNCE );
String strDescriptionAnnounce = request.getParameter( PARAMETER_DESCRIPTION_ANNOUNCE );
String strContactInformation = request.getParameter( PARAMETER_CONTACT_INFORMATION );
String strTags = request.getParameter( PARAMETER_TAGS );
Double nPriceAnnounce = ( request.getParameter( PARAMETER_PRICE_ANNOUNCE ) == null ) ? 0.0
: Double.parseDouble( request.getParameter( PARAMETER_PRICE_ANNOUNCE ) );
if ( StringUtils.isEmpty( strTitleAnnounce ) || StringUtils.isEmpty( strDescriptionAnnounce ) || StringUtils.isEmpty( strContactInformation )
|| ( category.getDisplayPrice( ) && category.getPriceMandatory( ) && ( nPriceAnnounce == 0.0 ) ) )
{
SiteMessageService.setMessage( request, Messages.MANDATORY_FIELDS, SiteMessage.TYPE_STOP );
return new ArrayList<>( ); |
File |
Line |
fr/paris/lutece/plugins/announce/web/CategoryJspBean.java |
276 |
fr/paris/lutece/plugins/announce/web/CategoryJspBean.java |
403 |
String strCategoryLabel = request.getParameter( PARAMETER_CATEGORY_LABEL );
int nIdSector = Integer.parseInt( request.getParameter( PARAMETER_CATEGORY_SECTOR_ID ) );
int nAnnouncesValidation = Integer.parseInt( request.getParameter( PARAMETER_CATEGORY_ANNOUNCES_VALIDATION ) );
String strDisplayPrice = request.getParameter( PARAMETER_DISPLAY_PRICE );
int nIdMailingList = Integer.parseInt( request.getParameter( PARAMETER_MAILING_LIST_ID ) );
int nIdWorkflow = Integer.parseInt( request.getParameter( PARAMETER_ID_WORKFLOW ) != null ? request.getParameter( PARAMETER_ID_WORKFLOW ) : "-1" );
boolean bDisplayCaptcha = Boolean.parseBoolean( request.getParameter( PARAMETER_DISPLAY_CAPTCHA ) );
boolean bPriceMandatory = Boolean.parseBoolean( request.getParameter( PARAMETER_PRICE_MANDATORY ) );
// Mandatory sectors
if ( ( nIdSector == 0 ) || StringUtils.isEmpty( strCategoryLabel ) ) |
File |
Line |
fr/paris/lutece/plugins/announce/business/AnnounceHome.java |
298 |
fr/paris/lutece/plugins/announce/business/AnnounceHome.java |
329 |
_dao.setPublished( announce, _plugin );
if ( announce.getPublished( ) && !announce.getSuspended( ) && !announce.getSuspendedByUser( ) )
{
AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_CREATE, _plugin );
}
else
{
AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_DELETE, _plugin );
}
AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getListIdPublishedAnnouncesCacheKey( ) );
AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getAnnounceCacheKey( announce.getId( ) ) );
}
public static void setHasNotifed( Announce announce ) |
File |
Line |
fr/paris/lutece/plugins/announce/business/AnnounceHome.java |
298 |
fr/paris/lutece/plugins/announce/business/AnnounceHome.java |
329 |
fr/paris/lutece/plugins/announce/business/AnnounceHome.java |
353 |
_dao.setPublished( announce, _plugin );
if ( announce.getPublished( ) && !announce.getSuspended( ) && !announce.getSuspendedByUser( ) )
{
AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_CREATE, _plugin );
}
else
{
AnnounceSearchService.getInstance( ).addIndexerAction( announce.getId( ), IndexerAction.TASK_DELETE, _plugin );
}
AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getListIdPublishedAnnouncesCacheKey( ) );
AnnounceCacheService.getService( ).removeKey( AnnounceCacheService.getAnnounceCacheKey( announce.getId( ) ) );
}
public static void setHasNotifed( Announce announce ) |