Commit a1ef9543 authored by Bert Leunis's avatar Bert Leunis

ESSCOM-15 Reintegrate bugfix/ESSCOM-15

parents 65a401db 228eda8e
/*
* Copyright 2014-2015 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-2016 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -228,7 +228,9 @@ public class EssentialsListComponent extends CommonComponent {
if (log.isDebugEnabled()) {
log.debug("Searching for document types: {}, and including subtypes: {}", documentTypes, paramInfo.getIncludeSubtypes());
}
return HstQueryBuilder.create(scope).ofTypes(types).build();
HstQueryBuilder builder = HstQueryBuilder.create(scope);
return paramInfo.getIncludeSubtypes() ? builder.ofTypes(types).build() : builder.ofPrimaryTypes(types).build();
}
@Deprecated
......
......@@ -29,7 +29,7 @@ public interface EssentialsListComponentInfo extends EssentialsPageable, Essenti
)
String getPath();
@Parameter(name = "includeSubtypes", required = false)
@Parameter(name = "includeSubtypes", defaultValue = "true", required = false)
Boolean getIncludeSubtypes();
@Parameter(name = "documentTypes", required = false)
......
......@@ -37,6 +37,8 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.onehippo.cms7.essentials.components.ext.DoBeforeRenderExtension;
import org.onehippo.cms7.essentials.components.info.EssentialsListComponentInfo;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
......@@ -48,6 +50,8 @@ public class EssentialsListComponentTest extends AbstractHstQueryTest {
private static final String NEWS_FOLDER_PATH = "/content/documents/myhippoproject/news";
private static final String CONTENT_FOLDER_PATH = "/content/documents/myhippoproject/content";
private static final int NR_NEWS_ITEMS = 3;
private static final int NR_MY_NEWS_ITEMS = 1;
private static final int TOTAL_NEWS_ITEMS = NR_NEWS_ITEMS + NR_MY_NEWS_ITEMS;
private static final int NR_CONTENT_ITEMS = 2;
private static final String MYHIPPOPROJECT_NEWSDOCUMENT = "myhippoproject:newsdocument";
......@@ -68,7 +72,7 @@ public class EssentialsListComponentTest extends AbstractHstQueryTest {
objectConverter = getObjectConverter();
obm = new ObjectBeanManagerImpl(session, objectConverter);
when(essentialsListComponentInfo.getIncludeSubtypes()).thenReturn(Boolean.FALSE);
when(essentialsListComponentInfo.getIncludeSubtypes()).thenReturn(TRUE);
when(componentManager.getComponent(DoBeforeRenderExtension.class.getName())).thenReturn(null);
HstServices.setComponentManager(componentManager);
}
......@@ -86,7 +90,18 @@ public class EssentialsListComponentTest extends AbstractHstQueryTest {
HstQueryResult hstQueryResult = executeHstQuery();
assertEquals(3, hstQueryResult.getSize());
assertEquals(TOTAL_NEWS_ITEMS, hstQueryResult.getSize());
}
@Test
public void testBuildHstQuery_News_NoSubtypes() throws ObjectBeanManagerException, QueryException {
when(essentialsListComponentInfo.getDocumentTypes()).thenReturn(MYHIPPOPROJECT_NEWSDOCUMENT);
when(essentialsListComponentInfo.getPath()).thenReturn(NEWS_FOLDER_PATH);
when(essentialsListComponentInfo.getIncludeSubtypes()).thenReturn(FALSE);
HstQueryResult hstQueryResult = executeHstQuery();
assertEquals(NR_NEWS_ITEMS, hstQueryResult.getSize());
}
@Test
......@@ -96,7 +111,7 @@ public class EssentialsListComponentTest extends AbstractHstQueryTest {
HstQueryResult hstQueryResult = executeHstQuery();
assertEquals(NR_NEWS_ITEMS, hstQueryResult.getSize());
assertEquals(TOTAL_NEWS_ITEMS, hstQueryResult.getSize());
}
@Test
......@@ -109,7 +124,6 @@ public class EssentialsListComponentTest extends AbstractHstQueryTest {
assertEquals(NR_CONTENT_ITEMS, hstQueryResult.getSize());
}
@Test
public void testBuildHstQuery_ContentAndNewsFromRoot() throws ObjectBeanManagerException, QueryException {
when(essentialsListComponentInfo.getDocumentTypes()).thenReturn(MYHIPPOPROJECT_NEWSDOCUMENT + "," + MYHIPPOPROJECT_CONTENTDOCUMENT);
......@@ -117,7 +131,7 @@ public class EssentialsListComponentTest extends AbstractHstQueryTest {
HstQueryResult hstQueryResult = executeHstQuery();
assertEquals(NR_CONTENT_ITEMS + NR_NEWS_ITEMS, hstQueryResult.getSize());
assertEquals(NR_CONTENT_ITEMS + TOTAL_NEWS_ITEMS, hstQueryResult.getSize());
}
private HstQueryResult executeHstQuery() throws ObjectBeanManagerException, QueryException {
......
......@@ -428,6 +428,85 @@
</sv:node>
</sv:node>
</sv:node>
<sv:node sv:name="mynews">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippo:handle</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>43da654e-cfbb-47a8-acc3-56c0035905cc</sv:value>
</sv:property>
<sv:node sv:name="mynews">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>myhippoproject:MyNews</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>42e47bd9-75dc-4c1d-a09d-990e427ca574</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="hippo:availability" sv:type="String">
<sv:value>live</sv:value>
</sv:property>
<sv:property sv:name="hippo:related___pathreference" sv:type="String"/>
<sv:property sv:name="hippostd:state" sv:type="String">
<sv:value>published</sv:value>
</sv:property>
<sv:property sv:name="hippostd:stateSummary" sv:type="String">
<sv:value>live</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:createdBy" sv:type="String">
<sv:value>admin</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:creationDate" sv:type="Date">
<sv:value>2016-12-01T16:57:00.126+01:00</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:lastModificationDate" sv:type="Date">
<sv:value>2016-12-01T16:57:26.302+01:00</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:lastModifiedBy" sv:type="String">
<sv:value>admin</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:publicationDate" sv:type="Date">
<sv:value>2016-12-01T16:57:29.171+01:00</sv:value>
</sv:property>
<sv:property sv:name="hippotranslation:id" sv:type="String">
<sv:value>10c852ef-2907-48ca-ad29-7c76f1cefd7e</sv:value>
</sv:property>
<sv:property sv:name="hippotranslation:locale" sv:type="String">
<sv:value>en</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:author" sv:type="String">
<sv:value>me</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:date" sv:type="Date">
<sv:value>2016-12-01T16:57:00.000+01:00</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:introduction" sv:type="String">
<sv:value>Not to be found</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:location" sv:type="String">
<sv:value>here</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:source" sv:type="String">
<sv:value>my thumb</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:title" sv:type="String">
<sv:value>Not to be found</sv:value>
</sv:property>
<sv:node sv:name="myhippoproject:content">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippostd:html</sv:value>
</sv:property>
<sv:property sv:name="hippostd:content" sv:type="String">
<sv:value>&lt;p&gt;Not to be found&lt;/p&gt;</sv:value>
</sv:property>
</sv:node>
</sv:node>
</sv:node>
</sv:node>
</sv:node>
</sv:node>
......@@ -13,3 +13,5 @@
[myhippoproject:newsdocument] > hippostd:relaxed, hippotranslation:translated, myhippoproject:basedocument
orderable
[myhippoproject:MyNews] > hippostd:relaxed, hippotranslation:translated, myhippoproject:newsdocument
orderable
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<sv:node sv:name="MyNews" xmlns:sv="http://www.jcp.org/jcr/sv/1.0">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposysedit:templatetype</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>2ad59286-f05f-40a9-850a-46d0612bd8cf</sv:value>
</sv:property>
<sv:node sv:name="hipposysedit:nodetype">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippo:handle</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>ef4e175e-023b-4bdb-a165-8a6268dfdf94</sv:value>
</sv:property>
<sv:node sv:name="hipposysedit:nodetype">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposysedit:nodetype</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
<sv:value>hipposysedit:remodel</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>3a4eb0dc-b4f1-45e5-9115-d173b51a7f24</sv:value>
</sv:property>
<sv:property sv:name="hipposysedit:node" sv:type="Boolean">
<sv:value>true</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="hipposysedit:supertype" sv:type="String">
<sv:value>myhippoproject:newsdocument</sv:value>
<sv:value>hippostd:relaxed</sv:value>
<sv:value>hippotranslation:translated</sv:value>
</sv:property>
<sv:property sv:name="hipposysedit:uri" sv:type="String">
<sv:value>http://www.onehippo.org/myhippoproject/nt/1.0</sv:value>
</sv:property>
</sv:node>
</sv:node>
<sv:node sv:name="hipposysedit:prototypes">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposysedit:prototypeset</sv:value>
</sv:property>
<sv:node sv:name="hipposysedit:prototype">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>myhippoproject:MyNews</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>d51ead2f-2466-4025-bd71-064a8bd24373</sv:value>
</sv:property>
<sv:property sv:name="hippo:related___pathreference" sv:type="String"/>
<sv:property sv:name="hippostd:holder" sv:type="String">
<sv:value>holder</sv:value>
</sv:property>
<sv:property sv:name="hippostd:state" sv:type="String">
<sv:value>draft</sv:value>
</sv:property>
<sv:property sv:name="hippostd:stateSummary" sv:type="String">
<sv:value>new</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:createdBy" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="hippostdpubwf:creationDate" sv:type="Date">
<sv:value>2016-12-01T16:56:34.434+01:00</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:lastModificationDate" sv:type="Date">
<sv:value>2016-12-01T16:56:34.434+01:00</sv:value>
</sv:property>
<sv:property sv:name="hippostdpubwf:lastModifiedBy" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="hippotranslation:id" sv:type="String">
<sv:value>document-type-locale-id</sv:value>
</sv:property>
<sv:property sv:name="hippotranslation:locale" sv:type="String">
<sv:value>document-type-locale</sv:value>
</sv:property>
<sv:property sv:name="myhippoproject:author" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="myhippoproject:introduction" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="myhippoproject:location" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="myhippoproject:source" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="myhippoproject:title" sv:type="String">
<sv:value/>
</sv:property>
<sv:node sv:name="myhippoproject:content">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippostd:html</sv:value>
</sv:property>
<sv:property sv:name="hippostd:content" sv:type="String">
<sv:value/>
</sv:property>
</sv:node>
<sv:node sv:name="myhippoproject:image">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippogallerypicker:imagelink</sv:value>
</sv:property>
<sv:property sv:name="hippo:docbase" sv:type="String">
<sv:value>cafebabe-cafe-babe-cafe-babecafebabe</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="hippo:facets" sv:type="String"/>
<sv:property sv:multiple="true" sv:name="hippo:modes" sv:type="String"/>
<sv:property sv:multiple="true" sv:name="hippo:values" sv:type="String"/>
</sv:node>
</sv:node>
</sv:node>
</sv:node>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment