View Javadoc

1   package de.tivsource.page.admin.actions.others.contententry;
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.menuentry.ContentEntry;
17  import de.tivsource.page.dao.contententry.ContentEntryDaoLocal;
18  import de.tivsource.page.dao.contentitem.ContentItemDaoLocal;
19  import de.tivsource.page.dao.property.PropertyDaoLocal;
20  import de.tivsource.page.entity.contentitem.ContentItem;
21  
22  /**
23   * 
24   * @author Marc Michele
25   *
26   */
27  @TilesDefinitions({
28    @TilesDefinition(name="contentEntryAddForm",  extend = "adminTemplate", putAttributes = {
29      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
30      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
31      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/contententry/add_form.jsp")
32    }),
33    @TilesDefinition(name="contentEntryEditForm", extend = "adminTemplate", putAttributes = {
34      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
35      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
36      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/contententry/edit_form.jsp")
37    }),
38    @TilesDefinition(name="contentEntryDeleteForm", extend = "adminTemplate", putAttributes = {
39      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
40      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/contententry/delete_form.jsp")
41    })
42  })
43  public class FormAction extends EmptyAction {
44  
45  	/**
46  	 * Serial Version UID.
47  	 */
48  	private static final long serialVersionUID = -5131003689523423888L;
49  
50  	/**
51       * Statischer Logger der Klasse.
52       */
53      private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
54  
55  	@InjectEJB(name="ContentEntryDao")
56      private ContentEntryDaoLocal contentEntryDaoLocal;
57  
58  	@InjectEJB(name="ContentItemDao")
59      private ContentItemDaoLocal contentItemDaoLocal;
60  
61      @InjectEJB(name="PropertyDao")
62      private PropertyDaoLocal propertyDaoLocal;
63  
64  	private ContentEntry contentEntry;
65  
66  	private String uncheckContentEntry;
67  
68  	private List<ContentItem> contentItems;
69  	
70  	public ContentEntry getContentEntry() {
71          return contentEntry;
72      }
73  
74  	public void setContentEntry(String uncheckContentEntry) {
75          this.uncheckContentEntry = uncheckContentEntry;
76      }
77  
78      @Override
79      @Actions({
80          @Action(
81          		value = "editForm", 
82          		results = { @Result(name = "success", type="tiles", location = "contentEntryEditForm") }
83          ),
84          @Action(
85          		value = "addForm", 
86          		results = { @Result(name = "success", type="tiles", location = "contentEntryAddForm") }
87          ),
88          @Action(
89          		value = "deleteForm", 
90          		results = { @Result(name = "success", type="tiles", location = "contentEntryDeleteForm") }
91          )
92      })
93      public String execute() throws Exception {
94      	LOGGER.info("execute() aufgerufen.");
95  
96      	contentItems = contentItemDaoLocal.findAllUnassigned(0, contentItemDaoLocal.countAllUnassigned());
97  
98      	this.loadPageParameter();
99      	
100     	return SUCCESS;
101     }// Ende execute()
102 
103     public List<ContentItem> getContentItems() {
104     	return contentItems;
105     }
106 
107 	private void loadPageParameter() {
108 
109 		if( uncheckContentEntry != null && uncheckContentEntry != "" && uncheckContentEntry.length() > 0) {
110 			contentEntry = contentEntryDaoLocal.findByUuid(uncheckContentEntry);
111 			// Füge das aktuelle ContentItem hinzu damit es auch in der Liste auftaucht.
112 			contentItems.add(contentEntry.getContentItem());
113 		} else {
114 			contentEntry = new ContentEntry();
115 		}
116 
117 	}// Ende loadPageParameter()
118 
119 }// Ende class