Skip to content

Commit

Permalink
Issue 13192 edit mode cleanup (#13193)
Browse files Browse the repository at this point in the history
* #13164 untested work

* #13164 removes multitreefactory from hibernate, includes treefactory

* #13164 removes tree from inode and category hibernate

* #13164 removing old code

* core#13192 edit mode parsing

* #13192 edit mode parsing

* #13192 contenttool

* #13194 some untested fixes

* #13194 use map.getOrDefault methods

* #13194 loadObjectResults

* #13194 jenkins feedback fixes

* #13194 fixes the red

* #13192 Container+Content Resource

* #13192 adding widget support

* #13192 adding widget support

* #13192 container pulling

* Add lang variables and update edit contentlet save and cancel functions to report back to ng

* #13192 multitree updates

* #13192 removing templatecontainers import

* #13192 removing templatecontainers from hibernate

* #13192 allow multitree to be imported

* #13192 fixes import

* #13192 copying velocity work to new folder

* Update ContentSelector dojo widget to make it work with ng

* #13192 kinda running

* #13192 look ma, no red

* Fix ContentSelector select event

* Fix edit contentlet requires fields

* #13192 live mode working

* #13192 slow and steady

* #13192 live mode

* #13192 live mode working

* #13192 preview mode working exclaimation point

* #13192 readding the integration tests

* #13192 ContainerResourceWorking

* Merge remote-tracking branch 'remotes/origin/master' into issue-13192-edit-mode-cleanup

# Conflicts:
#	dotCMS/src/main/java/com/dotmarketing/util/TaskLocatorUtil.java

* #13192 CloseDB aspect fixed

* #13192 unable to save pages

* #13192 white space cleanup
  • Loading branch information
wezell authored and jgambarios committed Dec 27, 2017
1 parent 3a8b649 commit 76d9671
Show file tree
Hide file tree
Showing 259 changed files with 10,002 additions and 9,951 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void push_archived_issue5086 () throws Exception {
Identifier containerIdentifier = APILocator.getIdentifierAPI().find(containerId);
Identifier contenletIdentifier = APILocator.getIdentifierAPI().find(contentlet);
MultiTree multiTree = MultiTreeFactory.getMultiTree(htmlPageIdentifier, containerIdentifier,contenletIdentifier);
int contentletCount = MultiTreeFactory.getMultiTree(workinghtmlPageAsset.getInode()).size();
int contentletCount = MultiTreeFactory.getMultiTrees(workinghtmlPageAsset.getIdentifier()).size();

if (!InodeUtils.isSet(multiTree.getParent1()) && !InodeUtils.isSet(multiTree.getParent2()) && !InodeUtils.isSet(multiTree.getChild())) {
MultiTree mTree = new MultiTree(htmlPageIdentifier.getInode(), containerIdentifier.getInode(),
Expand All @@ -400,7 +400,7 @@ public void push_archived_issue5086 () throws Exception {
* Relating content to archived page
*/
multiTree = MultiTreeFactory.getMultiTree(htmlPageIdentifier, containerIdentifier,contenletIdentifier);
contentletCount = MultiTreeFactory.getMultiTree(workinghtmlPageAsset.getInode()).size();
contentletCount = MultiTreeFactory.getMultiTrees(workinghtmlPageAsset.getIdentifier()).size();

if (!InodeUtils.isSet(multiTree.getParent1()) && !InodeUtils.isSet(multiTree.getParent2()) && !InodeUtils.isSet(multiTree.getChild())) {
MultiTree mTree = new MultiTree(htmlPageIdentifier.getInode(), containerIdentifier.getInode(),
Expand Down Expand Up @@ -544,8 +544,8 @@ public void push_archived_issue5086 () throws Exception {
}


Assert.assertEquals(0,MultiTreeFactory.getMultiTree(workinghtmlPageAsset.getInode()).size());
Assert.assertEquals(0,MultiTreeFactory.getMultiTreeByChild(contentlet.getIdentifier()).size());
Assert.assertEquals(0,MultiTreeFactory.getMultiTrees(workinghtmlPageAsset.getInode()).size());
Assert.assertEquals(0,MultiTreeFactory.getMultiTreesByChild(contentlet.getIdentifier()).size());

folder = APILocator.getFolderAPI().findFolderByPath(folderPath, host, systemUser, false);
assertTrue(!UtilMethods.isSet(folder.getInode()));
Expand Down Expand Up @@ -708,7 +708,7 @@ public void push_container_issue5189 () throws Exception {
Identifier containerIdentifier = APILocator.getIdentifierAPI().find(containerId);
Identifier contenletIdentifier1 = APILocator.getIdentifierAPI().find(contentlet1);
MultiTree multiTree = MultiTreeFactory.getMultiTree(htmlPageIdentifier, containerIdentifier,contenletIdentifier1);
int contentletCount = MultiTreeFactory.getMultiTree(htmlPageIdentifier).size();
int contentletCount = MultiTreeFactory.getMultiTrees(htmlPageIdentifier).size();

if (!InodeUtils.isSet(multiTree.getParent1()) && !InodeUtils.isSet(multiTree.getParent2()) && !InodeUtils.isSet(multiTree.getChild())) {
MultiTree mTree = new MultiTree(htmlPageIdentifier.getInode(), containerIdentifier.getInode(),
Expand All @@ -718,7 +718,7 @@ public void push_container_issue5189 () throws Exception {

Identifier contenletIdentifier2 = APILocator.getIdentifierAPI().find(contentlet2);
multiTree = MultiTreeFactory.getMultiTree(htmlPageIdentifier, containerIdentifier,contenletIdentifier2);
contentletCount = MultiTreeFactory.getMultiTree(htmlPageIdentifier).size();
contentletCount = MultiTreeFactory.getMultiTrees(htmlPageIdentifier).size();

if (!InodeUtils.isSet(multiTree.getParent1()) && !InodeUtils.isSet(multiTree.getParent2()) && !InodeUtils.isSet(multiTree.getChild())) {
MultiTree mTree = new MultiTree(htmlPageIdentifier.getInode(), containerIdentifier.getInode(),
Expand All @@ -728,7 +728,7 @@ public void push_container_issue5189 () throws Exception {

Identifier contenletIdentifier3 = APILocator.getIdentifierAPI().find(contentlet3);
multiTree = MultiTreeFactory.getMultiTree(htmlPageIdentifier, containerIdentifier,contenletIdentifier3);
contentletCount = MultiTreeFactory.getMultiTree(htmlPageIdentifier).size();
contentletCount = MultiTreeFactory.getMultiTrees(htmlPageIdentifier).size();

if (!InodeUtils.isSet(multiTree.getParent1()) && !InodeUtils.isSet(multiTree.getParent2()) && !InodeUtils.isSet(multiTree.getChild())) {
MultiTree mTree = new MultiTree(htmlPageIdentifier.getInode(), containerIdentifier.getInode(),
Expand All @@ -741,7 +741,7 @@ public void push_container_issue5189 () throws Exception {
* Validations
*/
assertTrue(workinghtmlPageAsset.isLive());
contentletCount = MultiTreeFactory.getMultiTree(htmlPageIdentifier).size();
contentletCount = MultiTreeFactory.getMultiTrees(htmlPageIdentifier).size();
assertTrue(contentletCount == 3);

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dotcms.velocity;
package com.dotcms.rendering.velocity;

import org.apache.velocity.context.Context;
import org.junit.BeforeClass;
Expand All @@ -9,7 +9,7 @@
import static org.junit.Assert.*;
import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.business.CacheLocator;
import com.dotmarketing.util.VelocityUtil;
import com.dotcms.rendering.velocity.util.VelocityUtil;

/**
* VelocityUtilTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.dotcms.velocity;
package com.dotcms.rendering.velocity;

import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.VelocityUtil;
import com.dotcms.rendering.velocity.util.VelocityUtil;

import org.junit.Assert;
import org.junit.BeforeClass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dotmarketing.viewtools;
package com.dotcms.rendering.velocity.viewtools;

import com.dotcms.IntegrationTestBase;
import com.dotcms.contenttype.exception.NotFoundInDbException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dotmarketing.viewtools;
package com.dotcms.rendering.velocity.viewtools;

import static com.dotcms.contenttype.model.type.KeyValueContentType.MULTILINGUABLE_FALLBACK_KEY;
import static org.junit.Assert.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dotmarketing.viewtools.content;
package com.dotcms.rendering.velocity.viewtools.content;

import com.dotcms.IntegrationTestBase;
import com.dotcms.contenttype.model.type.ContentType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dotmarketing.viewtools.navigation;
package com.dotcms.rendering.velocity.viewtools.navigation;

import com.dotcms.IntegrationTestBase;
import com.dotcms.rendering.velocity.viewtools.LanguageWebAPI;
import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.beans.Host;
import com.dotmarketing.beans.Identifier;
Expand All @@ -10,7 +11,7 @@
import com.dotmarketing.portlets.folders.model.Folder;
import com.dotmarketing.portlets.htmlpageasset.model.IHTMLPage;
import com.dotmarketing.util.Config;
import com.dotmarketing.viewtools.LanguageWebAPI;

import com.liferay.portal.model.User;

import org.junit.AfterClass;
Expand Down Expand Up @@ -65,14 +66,14 @@ public void testAboutUsDefaultPageToLanguageTrue() throws Exception { // https:/
//Using Identifier to get the path.
Identifier aboutUsIdentifier=APILocator.getIdentifierAPI().find(aboutUsFolder);

NavResult navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 1, user);
NavResult navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 1, user);
assertNotNull(navResult);

//We are expecting 3 children result for English Language.
int englishResultChildren = navResult.getChildren().size();
assertEquals(englishResultChildren, 3);

navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
assertNotNull(navResult);

int spanishResultChildren = navResult.getChildren().size();
Expand All @@ -86,7 +87,7 @@ public void testAboutUsDefaultPageToLanguageTrue() throws Exception { // https:/

createSpanishPagesCopy(user, liveHTMLPages, contentletsCreated);

navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
assertNotNull(navResult);

//Now We are expecting more children result for Spanish Language than English Language.
Expand All @@ -98,7 +99,7 @@ public void testAboutUsDefaultPageToLanguageTrue() throws Exception { // https:/
APILocator.getContentletAPI().delete(contentletsCreated, user, false);

//We should back to 2 in Spanish Nav.
navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
assertNotNull(navResult);

//Now We are expecting original amount children result for Spanish Language.
Expand All @@ -125,14 +126,14 @@ public void testAboutUsDefaultPageToLanguageFalse() throws Exception { // https:
//Using Identifier to get the path.
Identifier aboutUsIdentifier=APILocator.getIdentifierAPI().find(aboutUsFolder);

NavResult navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 1, user);
NavResult navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 1, user);
assertNotNull(navResult);

//We are expecting 3 children result for English Language.
int englishResultChildren = navResult.getChildren().size();
assertEquals(englishResultChildren, 3);

navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
assertNotNull(navResult);

int spanishResultChildren = navResult.getChildren().size();
Expand All @@ -146,7 +147,7 @@ public void testAboutUsDefaultPageToLanguageFalse() throws Exception { // https:

createSpanishPagesCopy(user, liveHTMLPages, contentletsCreated);

navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
assertNotNull(navResult);

//Now We are expecting same children result for Spanish Language and English Language.
Expand All @@ -158,7 +159,7 @@ public void testAboutUsDefaultPageToLanguageFalse() throws Exception { // https:
APILocator.getContentletAPI().delete(contentletsCreated, user, false);

//We should back to 2 in Spanish Nav.
navResult = NavTool.getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
navResult = new NavTool().getNav(demoHost, aboutUsIdentifier.getPath(), 2, user);
assertNotNull(navResult);

//Now We are expecting original amount children result for Spanish Language.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package com.dotmarketing.factories;

import static org.junit.Assert.assertTrue;

import com.dotcms.IntegrationTestBase;
import com.dotcms.util.IntegrationTestInitService;

import com.dotmarketing.beans.MultiTree;
import com.dotmarketing.startup.runonce.Task04315UpdateMultiTreePK;
import com.dotmarketing.util.Logger;

import java.util.List;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class MultiTreeFactoryTest extends IntegrationTestBase {


private static final String CONTAINER = "CONTAINER";
private static final String PAGE = "PAGE";
private static final String CONTENTLET = "CONTENTLET";
private static final String RELATION_TYPE = "RELATION_TYPE";

final static int runs =2;
final static int contentlets =5;
@BeforeClass
public static void initData() throws Exception {
IntegrationTestInitService.getInstance().init();
// testUpgradeTask();
buildInitalData();
}

public static void testUpgradeTask() throws Exception {
Task04315UpdateMultiTreePK task = Task04315UpdateMultiTreePK.class.newInstance();
task.executeUpgrade();
}


public static void buildInitalData() throws Exception {
for(int i=0;i<runs;i++) {
for(int j=0;j<contentlets;j++) {
MultiTree mt = new MultiTree()
.setContainer(CONTAINER +i)
.setHtmlPage(PAGE)
.setContentlet(CONTENTLET + j)
.setTreeOrder(j)
.setRelationType(RELATION_TYPE + i);

MultiTreeFactory.saveMultiTree(mt);
}
}

}

@Test
public void testDeletes() throws Exception {
deleteInitialData();
buildInitalData() ;
List<MultiTree> all = MultiTreeFactory.getAllMultiTrees();

List<MultiTree> list = MultiTreeFactory.getMultiTrees(PAGE);

deleteInitialData();
assertTrue("multiTree deletes", MultiTreeFactory.getAllMultiTrees().size() < all.size() );
assertTrue("multiTree deletes", MultiTreeFactory.getAllMultiTrees().size() == all.size() - list.size() );
}


@Test
public void testReorder() throws Exception {
deleteInitialData();
buildInitalData() ;
MultiTree tree = MultiTreeFactory.getMultiTree(PAGE, CONTAINER+0, CONTENTLET +0, RELATION_TYPE+0);
assertTrue("multiTree reorders", tree.getTreeOrder()==0 );
MultiTreeFactory.saveMultiTree(tree.setTreeOrder(7));
tree = MultiTreeFactory.getMultiTree(PAGE, CONTAINER+ 0, CONTENTLET + 0, RELATION_TYPE+0);
assertTrue("multiTree reorders", tree.getTreeOrder()==4 );
MultiTreeFactory.saveMultiTree(tree.setTreeOrder(2));
List<MultiTree> list = MultiTreeFactory.getMultiTrees(PAGE, CONTAINER+0, RELATION_TYPE+0);
assertTrue("multiTree reorders", list.get(2).equals(tree));

}

@Test
public void findByChild() throws Exception {
deleteInitialData();
buildInitalData() ;

List<MultiTree> list = MultiTreeFactory.getMultiTreesByChild(CONTENTLET + "0");

assertTrue("getByChild returns all results", list.size() == runs );



}



@AfterClass
public static void deleteInitialData() throws Exception {

List<MultiTree> list = MultiTreeFactory.getMultiTrees(PAGE);

for(MultiTree tree : list) {
MultiTreeFactory.deleteMultiTree(tree);
}

}





@Test
public void testSaveMultiTree() throws Exception {
MultiTree mt = new MultiTree()
.setContainer(CONTAINER)
.setHtmlPage(PAGE)
.setContentlet("NEW_ONE")
.setTreeOrder(0)
.setRelationType(RELATION_TYPE + 0);

MultiTreeFactory.saveMultiTree(mt);

MultiTree mt2 = MultiTreeFactory.getMultiTree(mt.getHtmlPage(), mt.getContainer(), mt.getContentlet(), mt.getRelationType());
assertTrue("multiTree save and get equals", mt.equals(mt2));








}










@Test
public void testGetMultiTreeIdentifierIdentifierIdentifierString() throws Exception {




}

@Test
public void testGetMultiTreeInode() throws Exception {

}

}
Loading

0 comments on commit 76d9671

Please sign in to comment.