View Javadoc

1   package de.tivsource.page.admin.actions.others.subsumption;
2   
3   import java.util.List;
4   
5   import org.apache.logging.log4j.LogManager;
6   import org.apache.logging.log4j.Logger;
7   import org.apache.struts2.convention.annotation.Action;
8   import org.apache.struts2.convention.annotation.Actions;
9   import org.apache.struts2.convention.annotation.Result;
10  import org.apache.struts2.tiles.annotation.TilesDefinition;
11  import org.apache.struts2.tiles.annotation.TilesDefinitions;
12  import org.apache.struts2.tiles.annotation.TilesPutAttribute;
13  
14  import de.tivsource.ejb3plugin.InjectEJB;
15  import de.tivsource.page.admin.actions.EmptyAction;
16  import de.tivsource.page.common.css.CSSGroup;
17  import de.tivsource.page.dao.contentitem.ContentItemDaoLocal;
18  import de.tivsource.page.dao.cssgroup.CSSGroupDaoLocal;
19  import de.tivsource.page.dao.picture.PictureDaoLocal;
20  import de.tivsource.page.dao.property.PropertyDaoLocal;
21  import de.tivsource.page.dao.subsumption.SubsumptionDaoLocal;
22  import de.tivsource.page.entity.contentitem.ContentItem;
23  import de.tivsource.page.entity.picture.Picture;
24  import de.tivsource.page.entity.subsumption.Subsumption;
25  
26  /**
27   * 
28   * @author Marc Michele
29   *
30   */
31  @TilesDefinitions({
32    @TilesDefinition(name="subsumptionAddForm",  extend = "adminTemplate", putAttributes = {
33      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
34      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
35      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/subsumption/add_form.jsp")
36    }),
37    @TilesDefinition(name="subsumptionEditForm", extend = "adminTemplate", putAttributes = {
38      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
39      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
40      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/subsumption/edit_form.jsp")
41    }),
42    @TilesDefinition(name="subsumptionDeleteForm", extend = "adminTemplate", putAttributes = {
43      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
44      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/subsumption/delete_form.jsp")
45    })
46  })
47  public class FormAction extends EmptyAction {
48  
49  	/**
50  	 * Serial Version UID.
51  	 */
52      private static final long serialVersionUID = -2984651595691911759L;
53  
54      /**
55       * Statischer Logger der Klasse.
56       */
57      private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
58  
59      @InjectEJB(name = "CSSGroupDao")
60      private CSSGroupDaoLocal cssGroupDaoLocal;
61  
62      @InjectEJB(name="ContentItemDao")
63      private ContentItemDaoLocal contentItemDaoLocal;
64  
65  	@InjectEJB(name="SubsumptionDao")
66      private SubsumptionDaoLocal subsumptionDaoLocal;
67  
68      @InjectEJB(name="PictureDao")
69      private PictureDaoLocal pictureDaoLocal;
70  
71      @InjectEJB(name="PropertyDao")
72      private PropertyDaoLocal propertyDaoLocal;
73  
74  	private Subsumption subsumption;
75  
76  	private String uncheckSubsumption;
77  
78  	private String lang = "DE";
79  
80      private List<Picture> pictureList;
81      
82      private List<CSSGroup> cssGroupList;
83  
84      private List<ContentItem> contentItems;
85  
86  	public Subsumption getSubsumption() {
87          return subsumption;
88      }
89  
90  	public void setSubsumption(String uncheckSubsumption) {
91          this.uncheckSubsumption = uncheckSubsumption;
92      }
93  
94  	public String getLang() {
95          return lang;
96      }
97  
98      public void setLang(String lang) {
99          this.lang = lang;
100     }
101 
102     @Override
103     public void prepare() {
104         super.prepare();
105         pictureList = pictureDaoLocal.findAll(propertyDaoLocal.findByKey("gallery.uuid.for.page.picture").getValue());
106         cssGroupList = cssGroupDaoLocal.findAll(0, cssGroupDaoLocal.countAll());
107     }
108 
109     @Override
110     @Actions({
111         @Action(
112         		value = "editForm", 
113         		results = { @Result(name = "success", type="tiles", location = "subsumptionEditForm") }
114         ),
115         @Action(
116         		value = "addForm", 
117         		results = { @Result(name = "success", type="tiles", location = "subsumptionAddForm") }
118         ),
119         @Action(
120         		value = "deleteForm", 
121         		results = { @Result(name = "success", type="tiles", location = "subsumptionDeleteForm") }
122         )
123     })
124     public String execute() throws Exception {
125     	LOGGER.info("execute() aufgerufen.");
126     	
127     	this.loadPageParameter();
128     	return SUCCESS;
129     }// Ende execute()
130 
131 	private void loadPageParameter() {
132 
133 		if( uncheckSubsumption != null && uncheckSubsumption != "" && uncheckSubsumption.length() > 0) {
134 		    contentItems = contentItemDaoLocal.findAllVisible(uncheckSubsumption, 0, contentItemDaoLocal.countAllVisible(uncheckSubsumption));
135 			subsumption = subsumptionDaoLocal.findByUuid(uncheckSubsumption);
136 		} else {
137 			subsumption = new Subsumption();
138 		}
139 
140 	}// Ende loadPageParameter()
141 
142     public List<Picture> getPictureList() {
143         return pictureList;
144     }
145 
146     public List<CSSGroup> getCssGroupList() {
147         LOGGER.info("getCssGroupList() aufgerufen.");
148         LOGGER.info("Anzahl der CSS-Gruppen in der Liste: " + cssGroupList.size());
149         return cssGroupList;
150     }
151 
152     /**
153      * @return the contentItems
154      */
155     public List<ContentItem> getContentItems() {
156         return contentItems;
157     }
158 
159 }// Ende class