001: /*
002: * EditItemStatus.java
003: *
004: * Version: $Revision: 1.3 $
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.item;
041:
042: import java.sql.SQLException;
043:
044: import org.apache.cocoon.environment.ObjectModelHelper;
045: import org.apache.cocoon.environment.Request;
046: import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
047: import org.dspace.app.xmlui.wing.Message;
048: import org.dspace.app.xmlui.wing.WingException;
049: import org.dspace.app.xmlui.wing.element.Body;
050: import org.dspace.app.xmlui.wing.element.Button;
051: import org.dspace.app.xmlui.wing.element.Division;
052: import org.dspace.app.xmlui.wing.element.List;
053: import org.dspace.app.xmlui.wing.element.PageMeta;
054: import org.dspace.app.xmlui.wing.element.Para;
055: import org.dspace.app.xmlui.wing.element.ReferenceSet;
056: import org.dspace.authorize.AuthorizeManager;
057: import org.dspace.content.Collection;
058: import org.dspace.content.Item;
059: import org.dspace.core.ConfigurationManager;
060:
061: /**
062: * Display basic meta-meta information about the item and allow the user to
063: * change it's state such as withdraw or reinstate, possibily even completely
064: * deleting the item!
065: *
066: * @author Jay Paz
067: * @author Scott Phillips
068: */
069:
070: public class ViewItem extends AbstractDSpaceTransformer {
071:
072: /** Language strings */
073: private static final Message T_dspace_home = message("xmlui.general.dspace_home");
074:
075: private static final Message T_item_trail = message("xmlui.administrative.item.general.item_trail");
076:
077: private static final Message T_option_head = message("xmlui.administrative.item.general.option_head");
078:
079: private static final Message T_option_status = message("xmlui.administrative.item.general.option_status");
080:
081: private static final Message T_option_bitstreams = message("xmlui.administrative.item.general.option_bitstreams");
082:
083: private static final Message T_option_metadata = message("xmlui.administrative.item.general.option_metadata");
084:
085: private static final Message T_option_view = message("xmlui.administrative.item.general.option_view");
086:
087: private static final Message T_title = message("xmlui.administrative.item.ViewItem.title");
088:
089: private static final Message T_trail = message("xmlui.administrative.item.ViewItem.trail");
090:
091: private static final Message T_head_parent_collections = message("xmlui.ArtifactBrowser.ItemViewer.head_parent_collections");
092: private static final Message T_show_simple = message("xmlui.ArtifactBrowser.ItemViewer.show_simple");
093:
094: private static final Message T_show_full = message("xmlui.ArtifactBrowser.ItemViewer.show_full");
095:
096: public void addPageMeta(PageMeta pageMeta) throws WingException {
097: pageMeta.addMetadata("title").addContent(T_title);
098:
099: pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
100: pageMeta
101: .addTrailLink(contextPath + "/admin/item", T_item_trail);
102: pageMeta.addTrail().addContent(T_trail);
103: }
104:
105: public void addBody(Body body) throws SQLException, WingException {
106: // Get our parameters and state
107: Request request = ObjectModelHelper.getRequest(objectModel);
108: String show = request.getParameter("show");
109: boolean showFullItem = false;
110: if (show != null && show.length() > 0)
111: showFullItem = true;
112:
113: int itemID = parameters.getParameterAsInteger("itemID", -1);
114: Item item = Item.find(context, itemID);
115: String baseURL = contextPath
116: + "/admin/item?administrative-continue=" + knot.getId();
117:
118: String link = baseURL + "&view_item"
119: + (showFullItem ? "" : "&show=full");
120: String tabLink = baseURL + "&view_item"
121: + (!showFullItem ? "" : "&show=full");
122: // DIVISION: main
123: Division main = body.addInteractiveDivision("edit-item-status",
124: contextPath + "/admin/item", Division.METHOD_POST,
125: "primary administrative edit-item-status");
126: main.setHead(T_option_head);
127:
128: // LIST: options
129: List options = main.addList("options", List.TYPE_SIMPLE,
130: "horizontal");
131: options.addItem().addXref(baseURL + "&submit_status",
132: T_option_status);
133: options.addItem().addXref(baseURL + "&submit_bitstreams",
134: T_option_bitstreams);
135: options.addItem().addXref(baseURL + "&submit_metadata",
136: T_option_metadata);
137: options.addItem().addHighlight("bold").addXref(tabLink,
138: T_option_view);
139:
140: // item
141:
142: Para showfullPara = main.addPara(null,
143: "item-view-toggle item-view-toggle-top");
144:
145: if (showFullItem) {
146: link = baseURL + "&view_item";
147: showfullPara.addXref(link).addContent(T_show_simple);
148: } else {
149: link = baseURL + "&view_item&show=full";
150: showfullPara.addXref(link).addContent(T_show_full);
151: }
152:
153: ReferenceSet referenceSet;
154: referenceSet = main.addReferenceSet("collection-viewer",
155: showFullItem ? ReferenceSet.TYPE_DETAIL_VIEW
156: : ReferenceSet.TYPE_SUMMARY_VIEW);
157: // Refrence the actual Item
158: ReferenceSet appearsInclude = referenceSet.addReference(item)
159: .addReferenceSet(ReferenceSet.TYPE_DETAIL_LIST, null,
160: "hierarchy");
161: appearsInclude.setHead(T_head_parent_collections);
162:
163: // Reference all collections the item appears in.
164: for (Collection collection : item.getCollections()) {
165: appearsInclude.addReference(collection);
166: }
167:
168: showfullPara = main.addPara(null,
169: "item-view-toggle item-view-toggle-bottom");
170:
171: if (showFullItem) {
172: showfullPara.addXref(link).addContent(T_show_simple);
173: } else {
174: showfullPara.addXref(link).addContent(T_show_full);
175: }
176: }
177: }
|