Author: DavidK Date: 2010-02-03 21:25:19 +0100 (Wed, 03 Feb 2010) New Revision: 1668 Modified: trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java Log: more inconsistent-db-state-proof preparation of planning component Modified: trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java =================================================================== --- trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java 2010-02-03 20:23:41 UTC (rev 1667) +++ trunk/server/webServer2/JavaSource/cz/elvys/webServer/beans/FilePlanningBean.java 2010-02-03 20:25:19 UTC (rev 1668) @@ -11,6 +11,8 @@ import javax.faces.event.ActionEvent; import javax.faces.model.SelectItem; +import junit.extensions.ActiveTestSuite; + import org.apache.log4j.Logger; import cz.elvys.commons.def.Constants; @@ -86,7 +88,6 @@ private Boolean reloadPanelsCountToShowOnNextPrepare = true; private Integer realCountOfPanelsToDisplayOnElvys = null; // count of panels to show on elvys private Integer panelsCountToShow = null; // count of panels to show - private Panel activePanel = null; // other fields private PlanDocumentBL plbl = null; @@ -223,12 +224,6 @@ public void setActiveCategory(Category activeCategory) { this.activeCategory = activeCategory; } - public Panel getActivePanel() { - return activePanel; - } - public void setActivePanel(Panel activePanel) { - this.activePanel = activePanel; - } public Elvys getElvys() { return elvys; } @@ -549,7 +544,6 @@ selected = null; categories = null; activeCategory = null; - activePanel = null; panelsToShow = null; // load elvys object @@ -566,8 +560,9 @@ if (activeCategory == null) { - // this GROUP has NO CATEGORY set.. - throw new NullPointerException("activeCategory"); + String message = CommonUtils.prepareErrorMessage( + "Group has no category", "groupId", elvysGroup.getId()); + throw new ExecuteException(message); } // if category changed, we need to reload basic amount of panels for this category @@ -602,15 +597,13 @@ } } - // select active panel - activePanel = selectActivePanel(panelsToShow, chosenPanelOrder); - if (activePanel == null) { - throw new NullPointerException("activePanel"); - } - - // get active layout Layout activeLayout = findActiveLayout(activeCategory); + if (activeLayout == null) { + String message = CommonUtils.prepareErrorMessage( + "category has no layout", "categoryId", activeCategory ); + throw new ExecuteException(message); + } this.layoutIDToPreview = activeLayout.getId(); // prepare layoutPreviewBean!! LayoutPreviewBean lpb = BeanManager.getLayoutPreview(); @@ -633,6 +626,7 @@ List<PanelOfRect> planningsOfAllPanels = new ArrayList<PanelOfRect>(); + // Timelines -> Planning Rectangles // iterate through each panel for (int i=0; i< panelsToShow.size(); i++) { List<List<Timeline>> onePanelPositions = panelsPositions.get(i); @@ -648,6 +642,12 @@ newLine.setRectangleList(rectList); // load position permitted type of documents List<ContentType> permittedTypes = pbl.loadPermittedTypesForThisPosition(activeLayout.getId(), lineId); + if (permittedTypes == null || permittedTypes.size()==0) { + String message = CommonUtils.prepareErrorMessage( + "no permitted types on layotuposition", "layoutId", activeLayout.getId(), + "position", lineId); + throw new ExecuteException(message); + } newLine.setPermittedTypes(permittedTypes); panelOfRect.getPanelLines().add(newLine); } @@ -762,38 +762,6 @@ return panels; } - private Panel selectActivePanel(List<Panel> panels, Integer reqPanelOrder) { - if (panels == null) { - throw new NullPointerException("categories"); - } - if (reqPanelOrder == null) { - throw new NullPointerException("reqCatId"); - } - - - - Panel result = null; - - // try to find required panel in list - for (Panel panel: panels) { - if (panel.getId().getOrderNum() == reqPanelOrder.intValue()) { - result = panel; - break; - } - } - - // choose another one from the list - if (panels.size() == 0) { - throw new RuntimeException("panels empty"); - } else { - result = panels.get(0); - } - - - return result; - } - - private Layout findActiveLayout(Category cat) throws Exception { if (cat == null) { throw new NullPointerException("catId");