001: /*
002: * EditCollectionMetadataForm.java
003: *
004: * Version: $Revision: 1.0 $
005: *
006: * Date: $Date: 2006/07/13 23:20:54 $
007: *
008: * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040: package org.dspace.app.xmlui.aspect.administrative.community;
041:
042: import java.sql.SQLException;
043:
044: import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
045: import org.dspace.app.xmlui.wing.Message;
046: import org.dspace.app.xmlui.wing.WingException;
047: import org.dspace.app.xmlui.wing.element.Body;
048: import org.dspace.app.xmlui.wing.element.Division;
049: import org.dspace.app.xmlui.wing.element.List;
050: import org.dspace.app.xmlui.wing.element.PageMeta;
051: import org.dspace.app.xmlui.wing.element.Para;
052: import org.dspace.app.xmlui.wing.element.Text;
053: import org.dspace.app.xmlui.wing.element.TextArea;
054: import org.dspace.authorize.AuthorizeException;
055: import org.dspace.content.Community;
056:
057: /**
058: * Presents the user with a form to enter the initial metadata for creation of a new community
059: * @author Alexey Maslov
060: */
061: public class CreateCommunityForm extends AbstractDSpaceTransformer {
062: /** Language Strings */
063: private static final Message T_dspace_home = message("xmlui.general.dspace_home");
064:
065: private static final Message T_title = message("xmlui.administrative.community.CreateCommunityForm.title");
066: private static final Message T_trail = message("xmlui.administrative.community.CreateCommunityForm.trail");
067:
068: private static final Message T_main_head_sub = message("xmlui.administrative.community.CreateCommunityForm.main_head_sub");
069: private static final Message T_main_head_top = message("xmlui.administrative.community.CreateCommunityForm.main_head_top");
070:
071: private static final Message T_label_name = message("xmlui.administrative.community.EditCommunityMetadataForm.label_name");
072: private static final Message T_label_short_description = message("xmlui.administrative.community.EditCommunityMetadataForm.label_short_description");
073: private static final Message T_label_introductory_text = message("xmlui.administrative.community.EditCommunityMetadataForm.label_introductory_text");
074: private static final Message T_label_copyright_text = message("xmlui.administrative.community.EditCommunityMetadataForm.label_copyright_text");
075: private static final Message T_label_side_bar_text = message("xmlui.administrative.community.EditCommunityMetadataForm.label_side_bar_text");
076: private static final Message T_label_logo = message("xmlui.administrative.community.EditCommunityMetadataForm.label_logo");
077:
078: private static final Message T_submit_save = message("xmlui.administrative.community.CreateCommunityForm.submit_save");
079: private static final Message T_submit_cancel = message("xmlui.general.cancel");
080:
081: public void addPageMeta(PageMeta pageMeta) throws WingException {
082: pageMeta.addMetadata("title").addContent(T_title);
083: pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
084: pageMeta.addTrail().addContent(T_trail);
085: }
086:
087: public void addBody(Body body) throws WingException, SQLException,
088: AuthorizeException {
089: int communityID = parameters.getParameterAsInteger(
090: "communityID", -1);
091: Community parentCommunity = Community
092: .find(context, communityID);
093:
094: // DIVISION: main
095: Division main = body.addInteractiveDivision("create-community",
096: contextPath + "/admin/community",
097: Division.METHOD_MULTIPART,
098: "primary administrative community");
099: /* Whether the parent community is null is what determines if
100: we are creating a top-level community or a sub-community */
101: if (parentCommunity != null)
102: main.setHead(T_main_head_sub.parameterize(parentCommunity
103: .getMetadata("name")));
104: else
105: main.setHead(T_main_head_top);
106:
107: // The grand list of metadata options
108: List metadataList = main.addList("metadataList", "form");
109:
110: // community name
111: metadataList.addLabel(T_label_name);
112: Text name = metadataList.addItem().addText("name");
113: name.setSize(40);
114:
115: // short description
116: metadataList.addLabel(T_label_short_description);
117: Text short_description = metadataList.addItem().addText(
118: "short_description");
119: short_description.setSize(40);
120:
121: // introductory text
122: metadataList.addLabel(T_label_introductory_text);
123: TextArea introductory_text = metadataList.addItem()
124: .addTextArea("introductory_text");
125: introductory_text.setSize(6, 40);
126:
127: // copyright text
128: metadataList.addLabel(T_label_copyright_text);
129: TextArea copyright_text = metadataList.addItem().addTextArea(
130: "copyright_text");
131: copyright_text.setSize(6, 40);
132:
133: // legacy sidebar text; may or may not be used for news
134: metadataList.addLabel(T_label_side_bar_text);
135: TextArea side_bar_text = metadataList.addItem().addTextArea(
136: "side_bar_text");
137: side_bar_text.setSize(6, 40);
138:
139: // the row to upload a new logo
140: metadataList.addLabel(T_label_logo);
141: metadataList.addItem().addFile("logo");
142:
143: Para buttonList = main.addPara();
144: buttonList.addButton("submit_save").setValue(T_submit_save);
145: buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
146:
147: main.addHidden("administrative-continue")
148: .setValue(knot.getId());
149: }
150: }
|