Author: DavidK Date: 2010-02-12 09:42:48 +0100 (Fri, 12 Feb 2010) New Revision: 1713 Added: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLTest.java Removed: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImplTest.java Modified: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBL.java trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImpl.java trunk/server/elvysCommons/src/elvys/server/bl/layoutrel/LayoutBLImpl.java trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/categrel/CatDefListBean.java trunk/server/webServer2/JavaSource/cz/elvys/webServer/messages/labels_cs.properties trunk/server/webServer2/WebContent/secured/categrel/catDefAssignStep2.xhtml trunk/server/webServer2/WebContent/secured/components/layoutListComponent.xhtml Log: (1) better planning, part 5. - moving back/forward in planning component (2) deleting of layout works now (except for label on modal win..) Modified: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBL.java =================================================================== --- trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBL.java 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBL.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -81,10 +81,15 @@ * @return count of updated rows in categoryDefinition table * @throws ExecuteException exception */ - public int removeCategoryDefinition(int catDefId) throws ExecuteException; + public int removeCategoryDefinitionMakeSession(int catDefId) throws ExecuteException; /** + * @see CategoryBL#removeCategoryDefinitionMakeSession(int) + */ + public int removeCategoryDefinition(int catDefId, Session sess) throws ExecuteException; + + /** * Assigns selected category definition to the elvys group. <br/> * Validation: <br/> * Group can't have assigned the same category definition more times. <br/> @@ -303,7 +308,26 @@ */ public List<CategoryDefinition> listCatDefinitionsOfCompany(Integer companyId, Session sess) throws ExecuteException; + + /** + * Returns all category definition objects that belong to the layout.<br/> + * Fetches: Layout and Layout.Company.<br/> + * Orders by 'created' (newer first) + * @param layoutId id of the layout + * @return list of category definition + */ + public List<CategoryDefinition> listCatDefinitionsForLayoutMakeSession(Integer layoutId) throws ExecuteException; + + + /** + * @see CategoryBL#listCatDefinitionsForLayoutMakeSession(Integer) + */ + public List<CategoryDefinition> listCatDefinitionsForLayout(Integer layoutId, Session sess) throws ExecuteException; + + + + /** * returns all category definition object which are used by given group * Fetches Layout and Layout.Company. Modified: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImpl.java =================================================================== --- trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImpl.java 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImpl.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -156,9 +156,23 @@ @Override - public int removeCategoryDefinition(int catDefId) throws ExecuteException { + public int removeCategoryDefinitionMakeSession(int catDefId) throws ExecuteException { Session sess = InitSessionFactory.getInstance().getCurrentSession(); Transaction tx = HibUtils.startTx(sess); + int res; + try { + res = removeCategoryDefinition(catDefId, sess); + tx.commit(); + } catch(Exception e) { + tx.rollback(); + throw new ExecuteException(e); + } + return res; + } + + @Override + public int removeCategoryDefinition(int catDefId, Session sess) + throws ExecuteException { int updatedRows; try { // get categoryDefinition @@ -190,10 +204,7 @@ catdef.setDisabled(true); sess.update(catdef); updatedRows = 1; - - tx.commit(); } catch (Exception e) { - tx.rollback(); String message = CommonUtils.prepareErrorMessage( CANNOT_REMOVE_CD, "catDefId", catDefId); throw new ExecuteException(message,e); @@ -421,6 +432,7 @@ Transaction tx = HibUtils.startTx(sess); try { takeAwayCategoryFromGroup(catId, groupId, sess); + tx.commit(); } catch(Exception e) { tx.rollback(); throw new ExecuteException(e); @@ -657,9 +669,7 @@ } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#listCatDefinitionsOfElvys(java.lang.Integer, org.hibernate.Session) - */ + @Override public List<CategoryDefinition> listCatDefinitionsOfElvys(Integer elvysId, Session sess) throws ExecuteException { List<CategoryDefinition> defs = null; @@ -679,9 +689,7 @@ } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#listCatDefinitionsOfGroupMakeSession(java.lang.Integer) - */ + @Override public List<CategoryDefinition> listCatDefinitionsOfGroupMakeSession(Integer elvysGroupId) throws ExecuteException { Session sess = InitSessionFactory.getInstance().getCurrentSession(); @@ -697,9 +705,7 @@ return list; } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#listCatDefinitionsOfGroup(java.lang.Integer, org.hibernate.Session) - */ + @Override public List<CategoryDefinition> listCatDefinitionsOfGroup(Integer elvysGroupId, Session sess) throws ExecuteException { List<CategoryDefinition> defs = null; @@ -720,9 +726,7 @@ - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#listCatDefintionsOfCompanyMakeSession(java.lang.Integer) - */ + @Override public List<CategoryDefinition> listCatDefinitionsOfCompanyMakeSession(Integer companyId) throws ExecuteException { Session sess = InitSessionFactory.getInstance().getCurrentSession(); @@ -738,9 +742,7 @@ return list; } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#listCatDefinitionsOfCompany(java.lang.Integer, org.hibernate.Session) - */ + @Override public List<CategoryDefinition> listCatDefinitionsOfCompany(Integer companyId, Session sess) throws ExecuteException { List<CategoryDefinition> list = null; @@ -763,8 +765,49 @@ return list; } + @Override + public List<CategoryDefinition> listCatDefinitionsForLayoutMakeSession( + Integer layoutId) throws ExecuteException { + Session sess = InitSessionFactory.getInstance().getCurrentSession(); + Transaction tx = HibUtils.startTx(sess); + List<CategoryDefinition> list = null; + try { + list = listCatDefinitionsForLayout(layoutId, sess); + tx.commit(); + } catch (Exception e) { + tx.rollback(); + throw new ExecuteException(e); + } + return list; + } + + @Override + public List<CategoryDefinition> listCatDefinitionsForLayout( + Integer layoutId, Session sess) throws ExecuteException { + List<CategoryDefinition> list = null; + try { + Query query = sess.createQuery("from CategoryDefinition cd " + + "inner join fetch cd.layout as l " + + "inner join fetch cd.layout.company as comp " + + "where cd.disabled = false " + + " and l.disabled = false " + + " and comp.disabled = false" + + " and l.id=:layoutId " + + "order by cd.created"); + query.setInteger("layoutId", layoutId); + list = query.list(); + } catch (Exception e) { + String message = CommonUtils.prepareErrorMessage( + CANNOT_LIST_CAT_DEF, "layoutId", layoutId); + throw new ExecuteException(message,e); + } + return list; + } + + + @Override public List<CategoryPlanning> listCatPlanningsForCompanyMakeSession( Integer companyId) throws ExecuteException { Session sess = InitSessionFactory.getInstance().getCurrentSession(); @@ -939,9 +982,7 @@ return panel; } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#getPanelById(java.lang.Integer, java.lang.Integer, org.hibernate.Session) - */ + @Override public Panel getPanelById(Integer planId, Integer ordNum, Session sess) throws ExecuteException { Panel panel = null; try { @@ -1099,9 +1140,7 @@ } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#getCategoryDefinitionById(java.lang.Integer, java.lang.Boolean) - */ + @Override public CategoryDefinition getCategoryDefinitionByIdMakesSession(Integer id, Boolean canBeDisabled) throws ExecuteException { Session sess = InitSessionFactory.getInstance().getCurrentSession(); Transaction tx = HibUtils.startTx(sess); @@ -1116,9 +1155,7 @@ return def; } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#getCategoryDefinitionById(java.lang.Integer, java.lang.Boolean, org.hibernate.Session) - */ + @Override public CategoryDefinition getCategoryDefinitionById(Integer id, Boolean canBeDisabled, Session sess) throws ExecuteException { CategoryDefinition def = null; try { @@ -1184,9 +1221,7 @@ return cat; } - /* (non-Javadoc) - * @see elvys.server.bl.categrel.CategoryBL#getCatByCatDefAndGroup(java.lang.Integer, java.lang.Integer) - */ + @Override public Category getCatByCatDefAndGroupMakeSession(Integer catDefId, Integer groupId) throws ExecuteException { Session sess = InitSessionFactory.getInstance().getCurrentSession(); Transaction tx = HibUtils.startTx(sess); Deleted: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImplTest.java =================================================================== --- trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImplTest.java 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImplTest.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -1,598 +0,0 @@ -package elvys.server.bl.categrel; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import static org.junit.Assert.*; - -import cz.elvys.webServer.HIBgen.Category; -import cz.elvys.webServer.HIBgen.CategoryDefinition; -import cz.elvys.webServer.HIBgen.CategoryPlanning; -import cz.elvys.webServer.HIBgen.ElvysGroup; -import cz.elvys.webServer.HIBgen.Panel; -import cz.elvys.webServer.HIBgen.Timeline; -import elvys.server.bl.Fact; -import elvys.server.bl.elvysrel.ElvysBL; -import elvys.server.bl.planning.PlanningBL; - -public class CategoryBLImplTest { - - // test params - private static final Integer companyId = 4; - - - // static fields - private static CategoryBL cbl = null; - private static ElvysBL ebl = null; - private static PlanningBL plbl = null; - - @BeforeClass - public static void init() { - cbl = Fact.getCategoryBL(); - ebl = Fact.getElvysBL(); - plbl = Fact.getPlanningBL(); - } - - @Test - public void testCreateCategoryDefinition() throws Exception { - throw new RuntimeException("not implemented yet"); - //ValidationResult createCategoryDefinition(Integer layoutId, String name, Integer companyId) - // throws ExecuteException { - } - - @Test - public void testUpdateCategoryDefinition() throws Exception { - throw new RuntimeException("not implemented yet"); - // ValidationResult updateCategoryDefinition(Integer cdId, String newName, Integer companyId) throws ExecuteException { - } - - @Test - public void testAssignCategoryDefinitionToGroupUnshared() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - @Test - public void testAssignCategoryDefinitionToGroupShared() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - @Test - public void testReassignCategoryToGroup() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - @Test - public void takeAwayCategoryFromGroup() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - @Test - public void testChangeCatDefLayout() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - @Test - public void WRITING_testReplicateCategoryPlanning() throws Exception { - int replicated=0; - - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); - for (CategoryPlanning pl: plannings) { - CategoryPlanning newPl = cbl.replicateCategoryPlanningMakeSession(pl.getId()); - - } - - - - assertTrue(replicated > 0); - } - - private boolean comparePlannings(CategoryPlanning pl1, CategoryPlanning pl2) { - -// List<Panel> panels1 = cbl.listPanelsForCatPlanningMakeSession(pl1.getId()); -// List<Panel> panels2 = cbl.listPanelsForCatPlanningMakeSession(pl2.getId()); -// assertTrue(panels1.size() == panels2.size()); -// List<Timeline> timelines = plbl.getTimelinesForOneLayoutPositionMakeSession(scheduleFrom, scheduleTo, panelPlanning, panelOrderNum, pos) - return false; - } - - - - - @Test - public void testListCatPlanningsForCatDefinition() throws Exception { - // count of plannings - Integer foundCount = 0; - // list definitions - List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(definitions); - - // lists of plannings - List<CategoryPlanning> allByCD = new ArrayList<CategoryPlanning>(); - for (CategoryDefinition d : definitions) { - CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); - assertCategoryPlanningsEmptyable(plannings); - allByCD.addAll(plannings); - foundCount += plannings.size(); - } - - List<CategoryPlanning> allByComp = cbl.listCatPlanningsForCompanyMakeSession(companyId); - assertTrue(allByComp.size() == allByCD.size()); - - assertTrue(foundCount > 0); - } - - @Test - public void testListCatPlanningsForCompany() throws Exception { - // count of plannings - Integer foundCount = 0; - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); - foundCount += plannings.size(); - - assertTrue(foundCount > 0); - } - - - @Test - public void testGetCategoryPlanningById() throws Exception { - // repeatedly loaded categoryplanning - Integer foundCount = 0; - - // list definitions - List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(definitions); - - // lists of plannings - for (CategoryDefinition d : definitions) { - CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); - assertCategoryPlanningsEmptyable(plannings); - - for(CategoryPlanning pl : plannings) { - int plid = pl.getId(); - CategoryPlanning newlyLoaded = cbl.getCategoryPlanningByIdMakeSession(plid); - assertCategoryPlanning(newlyLoaded); - foundCount++; - } - - } - assertTrue(foundCount > 0); - } - - @Test - public void testListPanelsForCatPlanning() throws Exception { - Integer foundCount = 0; - // list definitions - List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(definitions); - - // lists of plannings - for (CategoryDefinition d : definitions) { - CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); - assertCategoryPlanningsEmptyable(plannings); - - // panels - for (CategoryPlanning planning : plannings) { - List<Panel> panels = cbl.listPanelsForCatPlanningMakeSession(planning.getId()); - assertPanelsEmptyable(panels); - foundCount += panels.size(); - } - } - assertTrue(foundCount > 0); - } - - @Test - public void testGetPanelById() throws Exception { - Integer foundCount = 0; - // list definitions - List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(definitions); - - // lists of plannings - for (CategoryDefinition d : definitions) { - CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); - assertCategoryPlanningsEmptyable(plannings); - - // panels - for (CategoryPlanning planning : plannings) { - List<Panel> panels = cbl.listPanelsForCatPlanningMakeSession(planning.getId()); - assertPanelsEmptyable(panels); - - // reload panel by id - for (Panel panel : panels) { - Integer panelPl = panel.getId().getPlanning(); - Integer panelOrd = panel.getId().getOrderNum(); - Panel reloaded = cbl.getPanelByIdMakeSession(panelPl, panelOrd); - assertPanel(reloaded); - foundCount++; - } - } - } - assertTrue(foundCount > 0); - } - - @Ignore - @Test - // TODO - pozooooor, kazdemu planovani v DB prida jeden panel - public void WRITINGtestAddPanelTest() throws Exception { - Integer foundCount = 0; - // list definitions - List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(definitions); - - // lists of plannings - for (CategoryDefinition d : definitions) { - CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); - assertCategoryPlanningsEmptyable(plannings); - - // test add panel - if (plannings.size() > 0) { - for (CategoryPlanning plan: plannings) { - Integer maxOrdPre = cbl.getPanelMaxOrderMakeSession(plan.getId()); - Panel newOne = cbl.addPanelMakeSession(plan.getId()); - assertPanel(newOne); - Integer maxOrdPost = cbl.getPanelMaxOrderMakeSession(plan.getId()); - assertTrue(maxOrdPost.intValue() == maxOrdPre.intValue() + 1); - foundCount++; - } - } - } - assertTrue(foundCount > 0); - } - - @Test - public void testGetPanelMaxOrder() throws Exception { - // count of panels with max Order - int found = 0; - - // plannings of the company - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); - for (CategoryPlanning pl: plannings) { - // max. order - int order = cbl.getPanelMaxOrderMakeSession(pl.getId()); - assertTrue(order > -1); - found++; - } - assertTrue(found > 0); - } - - @Test - public void testGetPanelMaxUsedOrder() throws Exception { - // count of panels containing planning with max Order - int found = 0; - - // make up time interval - Date contextStart = new Date(); - Calendar cal = new GregorianCalendar(); - cal.setTime(contextStart); - cal.add(Calendar.DAY_OF_YEAR, 14); - Date contextEnd = cal.getTime(); - - // plannings of the company - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); - for (CategoryPlanning pl: plannings) { - // max order of used panel - int order = cbl.getPanelMaxUsedOrderMakeSession(pl.getId(), contextStart, contextEnd); - if(order > -1) { - found++; - } - } - assertTrue(found > 0); - } - - - @Test - public void testListCatDefinitionsOfElvys() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - - @Test - public void testListCatDefinitionsOfGroup() throws Exception { - throw new RuntimeException("not implemented yet"); - } - - @Test - public void listCatDefinitionsOfCompany() throws Exception { - // get all category definitions of the company - List<CategoryDefinition> list = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(list); - } - - @Test - public void testGetCategoryDefinitionById() throws Exception { - // get all category definitions of the company - List<CategoryDefinition> list = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - assertCatDefinitions(list); - - // choose one and get the one from the DB again - Integer chosenCatDefId = list.get(0).getId(); - CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(chosenCatDefId, false); - assertCatDefinition(def); - } - - @Test - public void testGetCategoryById() throws Exception { - // count of loaded(tested) categories - Integer foundCount = 0; - - // get groups of company - List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); - for (ElvysGroup eg : groups) { - - // get catDefs of group - List<Category> cats = cbl.listCategoriesForGroupMakeSession(eg.getId()); - assertCategoriesEmptyable(cats); - - // group+catdef => category - for (Category cat : cats) { - Integer catId = cat.getId(); - Category reloadedCat = cbl.getCategoryByIdMakeSession(catId); - assertCategory(reloadedCat); - foundCount++; - } - } - assertTrue(foundCount > 0); - } - - @Test - public void testGetCatByCatDefAndGroup() throws Exception { - Integer foundCount = 0; - // get groups of company - List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); - for (ElvysGroup eg : groups) { - - // get catDefs of group - List<CategoryDefinition> catdefs = cbl.listCatDefinitionsOfGroupMakeSession(eg.getId()); - assertCatDefinitionsEmptyable(catdefs); - - // group+catdef => category - for (CategoryDefinition catdef : catdefs) { - Category cat = cbl.getCatByCatDefAndGroupMakeSession(catdef.getId(), eg.getId()); - assertCategory(cat); - foundCount++; - } - } - assertTrue(foundCount > 0); - } - - // TODO otestovat test - @Test - public void testListCategoriesByCatDef() throws Exception { - // count of categories found by catdef - Integer foundCount = 0; - - - // categories gotten from catdefs - List<Category> categoriesToCheck = new ArrayList<Category>(); - List<CategoryDefinition> catDefs = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - for (CategoryDefinition catdef: catDefs) { - List<Category> categories = cbl.listCategoriesByCatDefMakeSession(catdef.getId()); - categoriesToCheck.addAll(categories); - } - - // categories gotten from groups (2nd list to compare) - List<Category> categoriesGR = new ArrayList<Category>(); - List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); - for (ElvysGroup group : groups) { - List<Category> categories = cbl.listCategoriesForGroupMakeSession(group.getId()); - categoriesGR.addAll(categories); - } - - assertTrue(categoriesToCheck.size()==categoriesGR.size()); - foundCount = categoriesToCheck.size(); - assertTrue(foundCount > 0); - } - - @Test - public void testListCategoriesForGroup() throws Exception { - Integer foundCount = 0; - List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); - for (ElvysGroup eg : groups) { - List<Category> categories = cbl.listCategoriesForGroupMakeSession(eg.getId()); - assertCategoriesEmptyable(categories); - foundCount += categories.size(); - } - assertTrue(foundCount > 0); - } - - - @Test - public void testListCategoriesForCatPlanning() throws Exception { - // count of categories gotten from plannning categories - Integer foundCount = 0; - - List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - for (CategoryDefinition def : definitions) { - List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); - for (CategoryPlanning pl : plannings) { - List<Category> categories = cbl.listCategoriesForCatPlanningMakeSession(pl.getId()); - // categoryPlanning exists => categories for this must be set - assertTrue(categories != null && categories.size() > 0); - foundCount ++; - } - } - assertTrue(foundCount > 0); - } - - @Test - public void testCatDefNameAlreadyExist() throws Exception { - - // category definitions - List<CategoryDefinition> catdefs = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); - - assertCatDefinitions(catdefs); - - // test new uniq name - String newUniqName = "DavidKusakTestujeDne3.1.2010"; - boolean exists1 = cbl.catDefNameAlreadyExistMakeSession( - newUniqName, companyId, new Integer[]{}); - assertFalse(exists1); - - // test ask for existing name - CategoryDefinition catDef = catdefs.get(0); - String existingName = catDef.getName(); - boolean exists2 = cbl.catDefNameAlreadyExistMakeSession( - existingName, companyId, new Integer[]{}); - assertTrue(exists2); - - // test ask for existing name - // with catDefId in excludesIds - Integer existingId = catDef.getId(); - boolean exists3 = cbl.catDefNameAlreadyExistMakeSession( - existingName, companyId, new Integer[]{existingId}); - assertFalse(exists3); - } - - @Test - public void testGetCategoryMaxOrder() throws Exception { - // maximal order of Group category with cat_order > 1 - Integer foundCount = 0; - - // get groups - List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); - for (ElvysGroup eg : groups) { - // get maximal order of category - Integer order = cbl.getCategoryMaxOrderMakeSession(eg.getId()); - if (order > 0) { - foundCount++; - } - } - assertTrue(foundCount > 0); - } - - - @Test - public void testSetCategoryOrder() throws Exception { - // TODO test - throw new RuntimeException("to implement"); - } - - @Test - public void testCorrectCategoriesOrder() throws Exception { - // TODO test - throw new RuntimeException("to implement"); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - private void assertCatDefinitions(List<CategoryDefinition> catDefs) { - assertTrue(catDefs != null && catDefs.size() > 0); - for (CategoryDefinition def : catDefs) { - assertCatDefinition(def); - } - } - private void assertCatDefinitionsEmptyable(List<CategoryDefinition> catDefs) { - assertTrue(catDefs != null); - for (CategoryDefinition def : catDefs) { - assertCatDefinition(def); - } - } - private void assertCatDefinition(CategoryDefinition def) { - assertTrue(def != null); - assertFalse(def.getDisabled()); - assertTrue(def.getLayout().getName() != null); - assertTrue(def.getLayout().getCompany().getName() != null); - } - - - private void assertCategories(List<Category> categories) { - assertTrue(categories != null && categories.size() > 0); - for (Category cat : categories) { - assertCategory(cat); - } - } - private void assertCategoriesEmptyable(List<Category> categories) { - assertTrue(categories != null); - for (Category cat : categories) { - assertCategory(cat); - } - } - private void assertCategory(Category cat) { - assertTrue(cat != null); - assertFalse(cat.isDisabled()); - assertTrue(cat.getCategoryDefinition().getName() != null); - assertTrue(cat.getCategoryPlanning().getId() != null); - } - - - - // assert category plannings - private void assertCategoryPlannings(List<CategoryPlanning> catPlannings) { - assertTrue(catPlannings != null && catPlannings.size() > 0); - for (CategoryPlanning catPlanning : catPlannings) { - assertCategoryPlanning(catPlanning); - } - } - private void assertCategoryPlanningsEmptyable(List<CategoryPlanning> catPlannings) { - assertTrue(catPlannings != null); - for (CategoryPlanning catPlanning : catPlannings) { - assertCategoryPlanning(catPlanning); - } - } - private void assertCategoryPlanning(CategoryPlanning cat) { - assertTrue(cat != null); - assertTrue(cat.getCategoryDefinition().getName() != null); - } - - - - - // assert panels - private void assertPanels(List<Panel> panels) { - assertTrue(panels != null && panels.size() > 0); - for (Panel panel : panels){ - assertPanel(panel); - } - } - private void assertPanelsEmptyable(List<Panel> panels) { - assertTrue(panels != null); - for (Panel panel : panels){ - assertPanel(panel); - } - } - private void assertPanel(Panel panel) { - assertTrue(panel != null); - assertTrue(panel.getId().getPlanning() != 0); - assertTrue(panel.getId().getOrderNum() != 0); - } - - -} - - - Copied: trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLTest.java (from rev 1588, trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLImplTest.java) =================================================================== --- trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLTest.java (rev 0) +++ trunk/server/elvysCommons/src/elvys/server/bl/categrel/CategoryBLTest.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -0,0 +1,619 @@ +package elvys.server.bl.categrel; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; + +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.*; + +import cz.elvys.webServer.HIBgen.Category; +import cz.elvys.webServer.HIBgen.CategoryDefinition; +import cz.elvys.webServer.HIBgen.CategoryPlanning; +import cz.elvys.webServer.HIBgen.ElvysGroup; +import cz.elvys.webServer.HIBgen.Layout; +import cz.elvys.webServer.HIBgen.Panel; +import elvys.server.bl.Fact; +import elvys.server.bl.elvysrel.ElvysBL; +import elvys.server.bl.layoutrel.LayoutBL; +import elvys.server.bl.planning.PlanningBL; + +public class CategoryBLTest { + + // test params + private static final Integer companyId = 4; + + + // static fields + private static CategoryBL cbl = null; + private static ElvysBL ebl = null; + private static PlanningBL plbl = null; + private static LayoutBL lbl = null; + + @BeforeClass + public static void init() { + cbl = Fact.getCategoryBL(); + ebl = Fact.getElvysBL(); + lbl = Fact.getLayoutBL(); + plbl = Fact.getPlanningBL(); + } + + @Test + public void testCreateCategoryDefinition() throws Exception { + throw new RuntimeException("not implemented yet"); + //ValidationResult createCategoryDefinition(Integer layoutId, String name, Integer companyId) + // throws ExecuteException { + } + + @Test + public void testUpdateCategoryDefinition() throws Exception { + throw new RuntimeException("not implemented yet"); + // ValidationResult updateCategoryDefinition(Integer cdId, String newName, Integer companyId) throws ExecuteException { + } + + @Test + public void testAssignCategoryDefinitionToGroupUnshared() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + @Test + public void testAssignCategoryDefinitionToGroupShared() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + @Test + public void testReassignCategoryToGroup() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + @Test + public void takeAwayCategoryFromGroup() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + @Test + public void testChangeCatDefLayout() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + @Test + public void WRITING_testReplicateCategoryPlanning() throws Exception { + int replicated=0; + + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); + for (CategoryPlanning pl: plannings) { + CategoryPlanning newPl = cbl.replicateCategoryPlanningMakeSession(pl.getId()); + + } + + + + assertTrue(replicated > 0); + } + + private boolean comparePlannings(CategoryPlanning pl1, CategoryPlanning pl2) { + +// List<Panel> panels1 = cbl.listPanelsForCatPlanningMakeSession(pl1.getId()); +// List<Panel> panels2 = cbl.listPanelsForCatPlanningMakeSession(pl2.getId()); +// assertTrue(panels1.size() == panels2.size()); +// List<Timeline> timelines = plbl.getTimelinesForOneLayoutPositionMakeSession(scheduleFrom, scheduleTo, panelPlanning, panelOrderNum, pos) + return false; + } + + + + + @Test + public void testListCatPlanningsForCatDefinition() throws Exception { + // count of plannings + Integer foundCount = 0; + // list definitions + List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(definitions); + + // lists of plannings + List<CategoryPlanning> allByCD = new ArrayList<CategoryPlanning>(); + for (CategoryDefinition d : definitions) { + CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); + assertCategoryPlanningsEmptyable(plannings); + allByCD.addAll(plannings); + foundCount += plannings.size(); + } + + List<CategoryPlanning> allByComp = cbl.listCatPlanningsForCompanyMakeSession(companyId); + assertTrue(allByComp.size() == allByCD.size()); + + assertTrue(foundCount > 0); + } + + @Test + public void testListCatPlanningsForCompany() throws Exception { + // count of plannings + Integer foundCount = 0; + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); + foundCount += plannings.size(); + + assertTrue(foundCount > 0); + } + + + @Test + public void testGetCategoryPlanningById() throws Exception { + // repeatedly loaded categoryplanning + Integer foundCount = 0; + + // list definitions + List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(definitions); + + // lists of plannings + for (CategoryDefinition d : definitions) { + CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); + assertCategoryPlanningsEmptyable(plannings); + + for(CategoryPlanning pl : plannings) { + int plid = pl.getId(); + CategoryPlanning newlyLoaded = cbl.getCategoryPlanningByIdMakeSession(plid); + assertCategoryPlanning(newlyLoaded); + foundCount++; + } + + } + assertTrue(foundCount > 0); + } + + @Test + public void testListPanelsForCatPlanning() throws Exception { + Integer foundCount = 0; + // list definitions + List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(definitions); + + // lists of plannings + for (CategoryDefinition d : definitions) { + CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); + assertCategoryPlanningsEmptyable(plannings); + + // panels + for (CategoryPlanning planning : plannings) { + List<Panel> panels = cbl.listPanelsForCatPlanningMakeSession(planning.getId()); + assertPanelsEmptyable(panels); + foundCount += panels.size(); + } + } + assertTrue(foundCount > 0); + } + + @Test + public void testGetPanelById() throws Exception { + Integer foundCount = 0; + // list definitions + List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(definitions); + + // lists of plannings + for (CategoryDefinition d : definitions) { + CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); + assertCategoryPlanningsEmptyable(plannings); + + // panels + for (CategoryPlanning planning : plannings) { + List<Panel> panels = cbl.listPanelsForCatPlanningMakeSession(planning.getId()); + assertPanelsEmptyable(panels); + + // reload panel by id + for (Panel panel : panels) { + Integer panelPl = panel.getId().getPlanning(); + Integer panelOrd = panel.getId().getOrderNum(); + Panel reloaded = cbl.getPanelByIdMakeSession(panelPl, panelOrd); + assertPanel(reloaded); + foundCount++; + } + } + } + assertTrue(foundCount > 0); + } + + @Ignore + @Test + // TODO - pozooooor, kazdemu planovani v DB prida jeden panel + public void WRITINGtestAddPanelTest() throws Exception { + Integer foundCount = 0; + // list definitions + List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(definitions); + + // lists of plannings + for (CategoryDefinition d : definitions) { + CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(d.getId(), false); + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); + assertCategoryPlanningsEmptyable(plannings); + + // test add panel + if (plannings.size() > 0) { + for (CategoryPlanning plan: plannings) { + Integer maxOrdPre = cbl.getPanelMaxOrderMakeSession(plan.getId()); + Panel newOne = cbl.addPanelMakeSession(plan.getId()); + assertPanel(newOne); + Integer maxOrdPost = cbl.getPanelMaxOrderMakeSession(plan.getId()); + assertTrue(maxOrdPost.intValue() == maxOrdPre.intValue() + 1); + foundCount++; + } + } + } + assertTrue(foundCount > 0); + } + + @Test + public void testGetPanelMaxOrder() throws Exception { + // count of panels with max Order + int found = 0; + + // plannings of the company + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); + for (CategoryPlanning pl: plannings) { + // max. order + int order = cbl.getPanelMaxOrderMakeSession(pl.getId()); + assertTrue(order > -1); + found++; + } + assertTrue(found > 0); + } + + @Test + public void testGetPanelMaxUsedOrder() throws Exception { + // count of panels containing planning with max Order + int found = 0; + + // make up time interval + Date contextStart = new Date(); + Calendar cal = new GregorianCalendar(); + cal.setTime(contextStart); + cal.add(Calendar.DAY_OF_YEAR, 14); + Date contextEnd = cal.getTime(); + + // plannings of the company + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCompanyMakeSession(companyId); + for (CategoryPlanning pl: plannings) { + // max order of used panel + int order = cbl.getPanelMaxUsedOrderMakeSession(pl.getId(), contextStart, contextEnd); + if(order > -1) { + found++; + } + } + assertTrue(found > 0); + } + + + @Test + public void testListCatDefinitionsOfElvys() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + + @Test + public void testListCatDefinitionsOfGroup() throws Exception { + throw new RuntimeException("not implemented yet"); + } + + @Test + public void testlistCatDefinitionsOfCompany() throws Exception { + // get all category definitions of the company + List<CategoryDefinition> list = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(list); + } + + @Test + public void testlistCatDefinitionsForLayout() throws Exception { + // found CD + int found = 0; + + // layouts + List<Layout> layouts = lbl.listLayoutsOfCompany(companyId); + for (Layout layout: layouts) { + + // get list CD for layout + List<CategoryDefinition> listCD = cbl.listCatDefinitionsForLayoutMakeSession(layout.getId()); + assertCatDefinitionsEmptyable(listCD); + found += listCD.size(); + } + + assertTrue(found > 0); + } + + @Test + public void testGetCategoryDefinitionById() throws Exception { + // get all category definitions of the company + List<CategoryDefinition> list = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + assertCatDefinitions(list); + + // choose one and get the one from the DB again + Integer chosenCatDefId = list.get(0).getId(); + CategoryDefinition def = cbl.getCategoryDefinitionByIdMakesSession(chosenCatDefId, false); + assertCatDefinition(def); + } + + @Test + public void testGetCategoryById() throws Exception { + // count of loaded(tested) categories + Integer foundCount = 0; + + // get groups of company + List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); + for (ElvysGroup eg : groups) { + + // get catDefs of group + List<Category> cats = cbl.listCategoriesForGroupMakeSession(eg.getId()); + assertCategoriesEmptyable(cats); + + // group+catdef => category + for (Category cat : cats) { + Integer catId = cat.getId(); + Category reloadedCat = cbl.getCategoryByIdMakeSession(catId); + assertCategory(reloadedCat); + foundCount++; + } + } + assertTrue(foundCount > 0); + } + + @Test + public void testGetCatByCatDefAndGroup() throws Exception { + Integer foundCount = 0; + // get groups of company + List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); + for (ElvysGroup eg : groups) { + + // get catDefs of group + List<CategoryDefinition> catdefs = cbl.listCatDefinitionsOfGroupMakeSession(eg.getId()); + assertCatDefinitionsEmptyable(catdefs); + + // group+catdef => category + for (CategoryDefinition catdef : catdefs) { + Category cat = cbl.getCatByCatDefAndGroupMakeSession(catdef.getId(), eg.getId()); + assertCategory(cat); + foundCount++; + } + } + assertTrue(foundCount > 0); + } + + // TODO otestovat test + @Test + public void testListCategoriesByCatDef() throws Exception { + // count of categories found by catdef + Integer foundCount = 0; + + + // categories gotten from catdefs + List<Category> categoriesToCheck = new ArrayList<Category>(); + List<CategoryDefinition> catDefs = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + for (CategoryDefinition catdef: catDefs) { + List<Category> categories = cbl.listCategoriesByCatDefMakeSession(catdef.getId()); + categoriesToCheck.addAll(categories); + } + + // categories gotten from groups (2nd list to compare) + List<Category> categoriesGR = new ArrayList<Category>(); + List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); + for (ElvysGroup group : groups) { + List<Category> categories = cbl.listCategoriesForGroupMakeSession(group.getId()); + categoriesGR.addAll(categories); + } + + assertTrue(categoriesToCheck.size()==categoriesGR.size()); + foundCount = categoriesToCheck.size(); + assertTrue(foundCount > 0); + } + + @Test + public void testListCategoriesForGroup() throws Exception { + Integer foundCount = 0; + List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); + for (ElvysGroup eg : groups) { + List<Category> categories = cbl.listCategoriesForGroupMakeSession(eg.getId()); + assertCategoriesEmptyable(categories); + foundCount += categories.size(); + } + assertTrue(foundCount > 0); + } + + + @Test + public void testListCategoriesForCatPlanning() throws Exception { + // count of categories gotten from plannning categories + Integer foundCount = 0; + + List<CategoryDefinition> definitions = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + for (CategoryDefinition def : definitions) { + List<CategoryPlanning> plannings = cbl.listCatPlanningsForCatDefinitionMakeSession(def.getId()); + for (CategoryPlanning pl : plannings) { + List<Category> categories = cbl.listCategoriesForCatPlanningMakeSession(pl.getId()); + // categoryPlanning exists => categories for this must be set + assertTrue(categories != null && categories.size() > 0); + foundCount ++; + } + } + assertTrue(foundCount > 0); + } + + @Test + public void testCatDefNameAlreadyExist() throws Exception { + + // category definitions + List<CategoryDefinition> catdefs = cbl.listCatDefinitionsOfCompanyMakeSession(companyId); + + assertCatDefinitions(catdefs); + + // test new uniq name + String newUniqName = "DavidKusakTestujeDne3.1.2010"; + boolean exists1 = cbl.catDefNameAlreadyExistMakeSession( + newUniqName, companyId, new Integer[]{}); + assertFalse(exists1); + + // test ask for existing name + CategoryDefinition catDef = catdefs.get(0); + String existingName = catDef.getName(); + boolean exists2 = cbl.catDefNameAlreadyExistMakeSession( + existingName, companyId, new Integer[]{}); + assertTrue(exists2); + + // test ask for existing name + // with catDefId in excludesIds + Integer existingId = catDef.getId(); + boolean exists3 = cbl.catDefNameAlreadyExistMakeSession( + existingName, companyId, new Integer[]{existingId}); + assertFalse(exists3); + } + + @Test + public void testGetCategoryMaxOrder() throws Exception { + // maximal order of Group category with cat_order > 1 + Integer foundCount = 0; + + // get groups + List<ElvysGroup> groups = ebl.listGroupByCompany(companyId); + for (ElvysGroup eg : groups) { + // get maximal order of category + Integer order = cbl.getCategoryMaxOrderMakeSession(eg.getId()); + if (order > 0) { + foundCount++; + } + } + assertTrue(foundCount > 0); + } + + + @Test + public void testSetCategoryOrder() throws Exception { + // TODO test + throw new RuntimeException("to implement"); + } + + @Test + public void testCorrectCategoriesOrder() throws Exception { + // TODO test + throw new RuntimeException("to implement"); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + private void assertCatDefinitions(List<CategoryDefinition> catDefs) { + assertTrue(catDefs != null && catDefs.size() > 0); + for (CategoryDefinition def : catDefs) { + assertCatDefinition(def); + } + } + private void assertCatDefinitionsEmptyable(List<CategoryDefinition> catDefs) { + assertTrue(catDefs != null); + for (CategoryDefinition def : catDefs) { + assertCatDefinition(def); + } + } + private void assertCatDefinition(CategoryDefinition def) { + assertTrue(def != null); + assertFalse(def.getDisabled()); + assertTrue(def.getLayout().getName() != null); + assertTrue(def.getLayout().getCompany().getName() != null); + } + + + private void assertCategories(List<Category> categories) { + assertTrue(categories != null && categories.size() > 0); + for (Category cat : categories) { + assertCategory(cat); + } + } + private void assertCategoriesEmptyable(List<Category> categories) { + assertTrue(categories != null); + for (Category cat : categories) { + assertCategory(cat); + } + } + private void assertCategory(Category cat) { + assertTrue(cat != null); + assertFalse(cat.isDisabled()); + assertTrue(cat.getCategoryDefinition().getName() != null); + assertTrue(cat.getCategoryPlanning().getId() != null); + } + + + + // assert category plannings + private void assertCategoryPlannings(List<CategoryPlanning> catPlannings) { + assertTrue(catPlannings != null && catPlannings.size() > 0); + for (CategoryPlanning catPlanning : catPlannings) { + assertCategoryPlanning(catPlanning); + } + } + private void assertCategoryPlanningsEmptyable(List<CategoryPlanning> catPlannings) { + assertTrue(catPlannings != null); + for (CategoryPlanning catPlanning : catPlannings) { + assertCategoryPlanning(catPlanning); + } + } + private void assertCategoryPlanning(CategoryPlanning cat) { + assertTrue(cat != null); + assertTrue(cat.getCategoryDefinition().getName() != null); + } + + + + + // assert panels + private void assertPanels(List<Panel> panels) { + assertTrue(panels != null && panels.size() > 0); + for (Panel panel : panels){ + assertPanel(panel); + } + } + private void assertPanelsEmptyable(List<Panel> panels) { + assertTrue(panels != null); + for (Panel panel : panels){ + assertPanel(panel); + } + } + private void assertPanel(Panel panel) { + assertTrue(panel != null); + assertTrue(panel.getId().getPlanning() != 0); + assertTrue(panel.getId().getOrderNum() != 0); + } + + +} + + + Modified: trunk/server/elvysCommons/src/elvys/server/bl/layoutrel/LayoutBLImpl.java =================================================================== --- trunk/server/elvysCommons/src/elvys/server/bl/layoutrel/LayoutBLImpl.java 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/elvysCommons/src/elvys/server/bl/layoutrel/LayoutBLImpl.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -14,12 +14,15 @@ import cz.elvys.commons.utils.CommonUtils; import cz.elvys.commons.utils.HibUtils; +import cz.elvys.webServer.HIBgen.CategoryDefinition; import cz.elvys.webServer.HIBgen.Elvys; import cz.elvys.webServer.HIBgen.FrameContent; import cz.elvys.webServer.HIBgen.Layout; import cz.elvys.webServer.HIBgen.Timeline; import cz.elvys.webServer.db.InitSessionFactory; import cz.elvys.webServer.toSpring.exception.ExecuteException; +import elvys.server.bl.Fact; +import elvys.server.bl.categrel.CategoryBL; public class LayoutBLImpl implements LayoutBL { @@ -28,10 +31,9 @@ private static final String UNABLE_LOAD_LAYOUTS = "Unable to load company layouts. CompanyId: "; private static final String UNABLE_LOAD_LAYOUT = "Couldn't load layout"; private static final String UNABLE_TO_MARK_LAYOUT_DELETED = "Unable to mark layout as \"deleted\""; - - /* (non-Javadoc) - * @see cz.elvys.webServer.bl.api.layoutrel.LayoutBL#getPresentLayout(java.lang.Integer, boolean) - */ + + + @Override public Layout getPresentLayout(Integer elvysID, boolean isDay) throws ExecuteException { try { Elvys elvys = null; @@ -199,14 +201,23 @@ - /* (non-Javadoc) - * @see cz.elvys.webServer.bl.api.layoutrel.LayoutBL#markLayoutAsDeleted(java.lang.Integer) - */ + @Override public void markLayoutAsDeleted(Integer layoutId) throws ExecuteException { Transaction tx = null; + Session sess = InitSessionFactory.getInstance().getCurrentSession(); + tx = HibUtils.startTx(sess); + try { - Session sess = InitSessionFactory.getInstance().getCurrentSession(); - tx = HibUtils.startTx(sess); + CategoryBL categoryBL = Fact.getCategoryBL(); + + // get CDs for layout + List<CategoryDefinition> listCD = categoryBL.listCatDefinitionsForLayout(layoutId,sess); + // remove all CDs from system + for(CategoryDefinition cd: listCD) { + categoryBL.removeCategoryDefinition(cd.getId(), sess); + } + + List<Layout> result = sess.createCriteria(Layout.class).add(Restrictions.idEq(layoutId)).list(); Layout layout = result.get(0); @@ -214,32 +225,14 @@ layout.setDisabled(true); sess.update(layout); - - // TODO taby - // set day/night elvys settings -// Set<ElvysSetting> onAsDay = layout.getElvysSettingsForDayLayout(); -// for (ElvysSetting setting : onAsDay) { -// setting.setLayoutByDayLayout(null); -// sess.save(setting); -// Elvys elvys = (Elvys) setting.getElvyses().iterator().next(); -// elvys.setActive(false); -// sess.save(elvys); + // let plannings and frcontents in DB +// // delete (!) plannings and frame contents +// Set<Timeline> timeList = layout.getTimelines(); +// for (Timeline timeline : timeList) { +// FrameContent frc = timeline.getFrameContent(); +// sess.delete(timeline); +// sess.delete(frc); // } -// Set<ElvysSetting> onAsNight = layout.getElvysSettingsForNightLayout(); -// for (ElvysSetting setting : onAsNight) { -// setting.setLayoutByNightLayout(null); -// setting.setNightMode(false); -// sess.save(setting); -// } - - - // delete (!) plannings and frame contents - Set<Timeline> timeList = layout.getTimelines(); - for (Timeline timeline : timeList) { - FrameContent frc = timeline.getFrameContent(); - sess.delete(timeline); - sess.delete(frc); - } tx.commit(); } catch (Exception e) { if (tx != null) { Modified: trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java =================================================================== --- trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -843,7 +843,8 @@ } public boolean canMoveBackward(Date schedulerStart) { - // start is in the past => false + + // (A)start is in the past => false if (new Date().after(schedulerStart)) { return false; } @@ -851,17 +852,15 @@ calFrom.setTime(schedulerStart); Calendar calToday = new GregorianCalendar(); calToday.setTime(new Date()); - // start is today => false - if (calFrom.get(Calendar.DAY_OF_MONTH) != calFrom.get(Calendar.DAY_OF_MONTH)) { + + // (B)start is today => false + if (calFrom.get(Calendar.DAY_OF_MONTH) == calToday.get(Calendar.DAY_OF_MONTH) && + calFrom.get(Calendar.MONTH) == calToday.get(Calendar.MONTH) && + calFrom.get(Calendar.YEAR) == calToday.get(Calendar.YEAR)) { return false; } - if (calFrom.get(Calendar.MONTH) != calToday.get(Calendar.MONTH)) { - return false; - } - if (calFrom.get(Calendar.YEAR) != calToday.get(Calendar.YEAR)) { - return false; - } - // start is tomorrow or late => true + + // (C)start is tomorrow or late => true return true; } Modified: trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/categrel/CatDefListBean.java =================================================================== --- trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/categrel/CatDefListBean.java 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/categrel/CatDefListBean.java 2010-02-12 08:42:48 UTC (rev 1713) @@ -101,7 +101,7 @@ } int updateRows; try { - updateRows = cbl.removeCategoryDefinition(selectedToDelete.getId()); + updateRows = cbl.removeCategoryDefinitionMakeSession(selectedToDelete.getId()); if (updateRows != 1) { throw new RuntimeException("strange count of deleted categoryDefinition.."); } Modified: trunk/server/webServer2/JavaSource/cz/elvys/webServer/messages/labels_cs.properties =================================================================== --- trunk/server/webServer2/JavaSource/cz/elvys/webServer/messages/labels_cs.properties 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/webServer2/JavaSource/cz/elvys/webServer/messages/labels_cs.properties 2010-02-12 08:42:48 UTC (rev 1713) @@ -134,7 +134,7 @@ layout.list.deletelayouttooltip=Sma\u017Ee dan\u00E9 rozvr\u017Een\u00ED dokument\u016F layout.list.createlayouttooltip=Nov\u00E9 rozvr\u017Een\u00ED dokument\u016F layout.list.modal.delete=Maz\u00E1n\u00ED rozvr\u017Een\u00ED -layout.list.modal.deletequestion= +layout.list.modal.deletequestion=Opravdu smazat toto rozvr\u017Een\u00ED layout.list.modal.deletecaution=Rozvr\u017Een\u00ED je nastaveno na n\u00E1sleduj\u00EDc\u00EDch kiosc\u00EDch. P\u0159esto smazat? layout.list.modal.yes=Ano layout.list.modal.no=Ne Modified: trunk/server/webServer2/WebContent/secured/categrel/catDefAssignStep2.xhtml =================================================================== --- trunk/server/webServer2/WebContent/secured/categrel/catDefAssignStep2.xhtml 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/webServer2/WebContent/secured/categrel/catDefAssignStep2.xhtml 2010-02-12 08:42:48 UTC (rev 1713) @@ -173,22 +173,22 @@ <br/> <!-- ASSIGN BUTTON --> - <a4j:commandButton + <h:commandButton id="AssignCatDefButton" value="#{lbl['catdef.assign.step2.assigncatdef']}" immediate="true" rendered="#{!catDefAssignStep2Bean.updating}" action="#{catDefAssignStep2Bean.assign}"> - </a4j:commandButton> + </h:commandButton> <!-- REASSIGN BUTTON --> - <a4j:commandButton + <h:commandButton id="ReassignCatDefButton" value="#{lbl['catdef.assign.step2.reassigncatdef']}" immediate="true" rendered="#{catDefAssignStep2Bean.updating}" action="#{catDefAssignStep2Bean.modify}"> - </a4j:commandButton> + </h:commandButton> </rich:panel> </h:form> </ui:define> Modified: trunk/server/webServer2/WebContent/secured/components/layoutListComponent.xhtml =================================================================== --- trunk/server/webServer2/WebContent/secured/components/layoutListComponent.xhtml 2010-02-11 18:18:46 UTC (rev 1712) +++ trunk/server/webServer2/WebContent/secured/components/layoutListComponent.xhtml 2010-02-12 08:42:48 UTC (rev 1713) @@ -85,7 +85,7 @@ <f:facet name="header">#{lbl['layout.list.preview']}</f:facet> <a4j:commandButton id="ShowLayoutImgButton" reRender="ModalShowLayoutImgContent" - onclick="Richfaces.showModalPanel('ModalShowLayoutImg',{left:50, top:50})" + onclick="Richfaces.showModalPanel('ModalShowLayoutImg')" image="/images/icons/detail.png"> <f:setPropertyActionListener value="#{layout.id}" target="#{layoutPreviewModalBean.layoutId}" /> @@ -200,7 +200,7 @@ <rich:modalPanel id="DeleteLayoutModal" minHeight="100" minWidth="200" - height="150" width="200" zindex="2000"> + autosized="true" zindex="2000"> <f:facet name="header"> <h:outputText value="#{lbl['layout.list.modal.delete']}" /> </f:facet> @@ -216,7 +216,8 @@ <center> <h:form id="DeleteLayoutForm"> <h:inputHidden value="#{layoutListComponentBean.layoutId}"/> - <b><h:outputText>#{lbl['layout.list.modal.deletequestion']}:</h:outputText></b> <br/> + <b><h:outputText value="#{lbl['layout.list.modal.deletequestion']}?"/></b> + <br/> <h:outputText value="#{layoutListComponentBean.layoutName}"/> <br/> <h:panelGroup rendered="#{not empty layoutListComponentBean.layoutId}">