Skip to content

HTMLDOCS-132 : Search criteria of blogs are not working #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/java/fr/paris/lutece/plugins/blog/business/Blog.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class Blog extends ReferenceItem implements Serializable, IExtendableReso

private List<Tag> _tag = new ArrayList<Tag>( );

private List<BlogPublication> _blogPubilcation = new ArrayList<BlogPublication>( );
private List<BlogPublication> _blogPublication = new ArrayList<BlogPublication>( );

/**
* Returns the Id
Expand Down Expand Up @@ -486,13 +486,13 @@ public void deleteTag( Tag tag )
}

/**
* Returns the blogPubilcation list
* Returns the blogPublication list
*
* @return The BlogPubilcation list
* @return The blogPublication list
*/
public List<BlogPublication> getBlogPubilcation( )
public List<BlogPublication> getBlogPublication( )
{
return _blogPubilcation;
return _blogPublication;
}

/**
Expand All @@ -501,37 +501,37 @@ public List<BlogPublication> getBlogPubilcation( )
* @param blogPublication
* list The blogPublication list
*/
public void setBlogPubilcation( List<BlogPublication> blogPublication )
public void setBlogPublication( List<BlogPublication> blogPublication )
{
_blogPubilcation = blogPublication;
_blogPublication = blogPublication;
}

/**
* Sets the BlogPubilcation list
* Sets the blogPublication list
*
* @param BlogPubilcation
* list The BlogPubilcation list
* @param blogPublication
* list The blogPublication list
*/
public void addBlogPublication( BlogPublication blogPubilcation )
public void addBlogPublication( BlogPublication blogPublication )
{

boolean isContain = _blogPubilcation.stream( ).anyMatch(
blogPub -> ( blogPub.getIdBlog( ) == blogPubilcation.getIdBlog( ) && blogPub.getIdPortlet( ) == blogPubilcation.getIdPortlet( ) ) );
boolean isContain = _blogPublication.stream( ).anyMatch(
blogPub -> ( blogPub.getIdBlog( ) == blogPublication.getIdBlog( ) && blogPub.getIdPortlet( ) == blogPublication.getIdPortlet( ) ) );

if ( !isContain )
_blogPubilcation.add( blogPubilcation );
_blogPublication.add( blogPublication );
}

/**
* delet the BlogPubilcation
* delet the blogPublication
*
* @param BlogPubilcation
* The BlogPubilcation
* @param blogPublication
* The blogPublication
*/
public void deleteBlogPublication( BlogPublication blogPubilcation )
public void deleteBlogPublication( BlogPublication blogPublication )
{

_blogPubilcation.removeIf( blogPub -> ( blogPub.getIdBlog( ) == blogPubilcation.getIdBlog( ) && blogPub.getIdPortlet( ) == blogPubilcation
_blogPublication.removeIf( blogPub -> ( blogPub.getIdBlog( ) == blogPublication.getIdBlog( ) && blogPub.getIdPortlet( ) == blogPublication
.getIdPortlet( ) ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public Blog loadBlog( int nIdDocument )
List<DocContent> docContent = DocContentHome.getDocsContentByHtmlDoc( nIdDocument );
blog.setDocContent( docContent );
blog.setTag( TagHome.loadByDoc( nIdDocument ) );
blog.setBlogPubilcation( BlogPublicationHome.getDocPublicationByIdDoc( nIdDocument ) );
blog.setBlogPublication( BlogPublicationHome.getDocPublicationByIdDoc( nIdDocument ) );

return blog;

Expand All @@ -332,7 +332,7 @@ public Blog findByPrimaryKeyWithoutBinaries( int nIdDocument )
{
Blog blog = BlogHome.findByPrimaryKey( nIdDocument );
blog.setTag( TagHome.loadByDoc( nIdDocument ) );
blog.setBlogPubilcation( BlogPublicationHome.getDocPublicationByIdDoc( nIdDocument ) );
blog.setBlogPublication( BlogPublicationHome.getDocPublicationByIdDoc( nIdDocument ) );

return blog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
public class BlogLuceneSearchEngine implements IBlogSearchEngine
{

private static final String WILDCARD = "*";

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -120,7 +122,7 @@ public int getSearchResults( BlogSearchFilter filter, Plugin plugin, List<Search
if ( filter.getUser( ) != null )
{

Term term = new Term( BlogSearchItem.FIELD_USER, filter.getUser( ) );
Term term = new Term( BlogSearchItem.FIELD_USER, filter.getUser( ) + WILDCARD );
Query termQuery = new TermQuery( term );
queries.add( termQuery.toString( ) );
sectors.add( BlogSearchItem.FIELD_USER );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ public static org.apache.lucene.document.Document getDocument( Blog blog ) throw

doc.add( new StringField( BlogSearchItem.FIELD_ID_HTML_DOC, Integer.toString( blog.getId( ) ), Field.Store.YES ) );
// Add the user firstName as a field, so that index can be incrementally maintained.
doc.add( new StringField( BlogSearchItem.FIELD_USER, blog.getUser( ), Field.Store.YES ) );
doc.add( new StringField( BlogSearchItem.FIELD_USER, blog.getUserCreator( ), Field.Store.YES ) );

doc.add( new TextField( BlogSearchItem.FIELD_TAGS, getTagToIndex( blog ), Field.Store.YES ) );
FieldType ft = new FieldType( StringField.TYPE_STORED );
ft.setOmitNorms( false );
doc.add( new Field( BlogSearchItem.FIELD_DATE, DateTools.timeToString( blog.getUpdateDate( ).getTime( ), DateTools.Resolution.MINUTE ), ft ) );
doc.add( new NumericDocValuesField( BlogSearchItem.FIELD_DATE_UPDATE, blog.getUpdateDate( ).getTime( ) ) );
doc.add( new TextField( BlogSearchItem.FIELD_UNPUBLISHED, ( blog.getBlogPubilcation( ).size( ) == 0 ) ? "true" : "false", Field.Store.YES ) );
doc.add( new TextField( BlogSearchItem.FIELD_UNPUBLISHED, ( blog.getBlogPublication( ).size( ) == 0 ) ? "true" : "false", Field.Store.YES ) );

// Add the uid as a field, so that index can be incrementally maintained.
// This field is not stored with question/answer, it is indexed, but it is not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public List<Document> getDocuments( String strDocumentId ) throws IOException, I
public void indexDocuments( ) throws IOException, InterruptedException, SiteMessageException
{
BlogSearchService.getInstance( ).processIndexing( true );
// DefaultblogIndexer.getDocuments("");
}

}
2 changes: 1 addition & 1 deletion src/java/fr/paris/lutece/plugins/blog/web/BlogJspBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ public String getPreviewBlog( HttpServletRequest request )
{
blog = BlogService.getInstance( ).loadBlog( nId );
}
blog.setBlogPubilcation( BlogPublicationHome.getDocPublicationByIdDoc( nId ) );
blog.setBlogPublication( BlogPublicationHome.getDocPublicationByIdDoc( nId ) );

Map<String, Object> model = getModel( );
model.put( MARK_LIST_TAG, TagHome.getTagsReferenceList( ) );
Expand Down
15 changes: 7 additions & 8 deletions webapp/WEB-INF/templates/admin/plugins/blog/manage_blogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
<div class="input-group">
<input type="text" class="form-control" id="search_text" name="search_text" value="${search_text!''}">
<div class="input-group-addon">
<label id="mydocs" for="current_user">
<input type="checkbox" name="current_user" id="current_user" value="true" <#if is_checked>checked</#if> title="#i18n{blog.manage_blogs.sortByUserButton}">
</label>
<label id="mydocs" for="current_user">#i18n{blog.manage_blogs.sortByUserButton}</label>
<input type="checkbox" name="current_user" id="current_user" value="true" <#if is_checked>checked</#if> title="#i18n{blog.manage_blogs.sortByUserButton}" />
</div>
</div>
</div>
Expand Down Expand Up @@ -156,19 +155,19 @@
<div class="btn-group">
<#if permission_manage_publish_blog>
<a href="jsp/admin/plugins/blog/ManagePublicationBlogs.jsp?view=manageBlogsPublication&amp;id=${blog.id}"
class="btn-publish btn btn-sm <#if blog.blogPubilcation?size == 0>btn-default<#else>btn-primary notif</#if>" title="<#if blog.blogPubilcation?size==0>Publier<#else>#i18n{blog.manage_blogs.managePublication}</#if>">
class="btn-publish btn btn-sm <#if blog.blogPublication?size == 0>btn-default<#else>btn-primary notif</#if>" title="<#if blog.blogPublication?size==0>Publier<#else>#i18n{blog.manage_blogs.managePublication}</#if>">
<i class="fa fa-globe"></i>
<#if blog.blogPubilcation?size &gt; 0>
<span class="notification left bg-purple-active">${blog.blogPubilcation?size}</span>
<#if blog.blogPublication?size &gt; 0>
<span class="notification left bg-purple-active">${blog.blogPublication?size}</span>
</#if>
</a>
<#if blog.blogPubilcation?size &gt; 0>
<#if blog.blogPublication?size &gt; 0>
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<#list blog.blogPubilcation?sort_by("idPortlet") as publication>
<#list blog.blogPublication?sort_by("idPortlet") as publication>
<li>
<div class="btn-group" role="group" aria-label="...">
<a href="jsp/admin/plugins/blog/ManagePublicationBlogs.jsp?action=unPublishDocument&amp;idDocument=${blog.id}&idPortlet=${publication.idPortlet}&id=${blog.id}"
Expand Down
10 changes: 5 additions & 5 deletions webapp/WEB-INF/templates/admin/plugins/blog/modify_blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<div class="box-header with-border">
<h4 class="box-title">
Publication
<#if blog.blogPubilcation?size &gt; 0>
<span class="notification left bg-purple-active">${blog.blogPubilcation?size}</span>
<#if blog.blogPublication?size &gt; 0>
<span class="notification left bg-purple-active">${blog.blogPublication?size}</span>
</#if>
</h4>
</div>
Expand All @@ -45,17 +45,17 @@ <h4 class="box-title">
<div class="panel-body">
<div class="box-body">
<a href="jsp/admin/plugins/blog/ManagePublicationBlogs.jsp?view=manageBlogsPublication&id=${blog.id}"
class="btn-publish btn btn-sm <#if blog.blogPubilcation?size == 0>btn-default<#else>btn-primary notif</#if>" title="<#if blog.blogPubilcation?size==0>Publier<#else>#i18n{blog.modify_blogs.managePublication}</#if>">
class="btn-publish btn btn-sm <#if blog.blogPublication?size == 0>btn-default<#else>btn-primary notif</#if>" title="<#if blog.blogPublication?size==0>Publier<#else>#i18n{blog.modify_blogs.managePublication}</#if>">
<i class="fa fa-globe"></i>

</a>
<#if blog.blogPubilcation?size &gt; 0>
<#if blog.blogPublication?size &gt; 0>
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<#list blog.blogPubilcation as publication>
<#list blog.blogPublication as publication>
<li>
<div class="btn-group" role="group" aria-label="...">
<a href="jsp/admin/plugins/blog/ManagePublicationBlogs.jsp?action=unPublishDocument&idDocument=${blog.id}&idPortlet=${publication.idPortlet}&id=${blog.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h3>#i18n{blog.publication_blog.labelPublishedPost}</h3>
</tr>
</thead>
<tbody>
<#list blog.blogPubilcation as pub>
<#list blog.blogPublication as pub>
<tr>
<td>
<#list portlet_list as portlet>
Expand Down