001: /*
002: * DeleteEPeopleConfirm.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.eperson;
041:
042: import java.sql.SQLException;
043: import java.util.ArrayList;
044:
045: import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
046: import org.dspace.app.xmlui.wing.Message;
047: import org.dspace.app.xmlui.wing.WingException;
048: import org.dspace.app.xmlui.wing.element.Body;
049: import org.dspace.app.xmlui.wing.element.Division;
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.Row;
053: import org.dspace.app.xmlui.wing.element.Table;
054: import org.dspace.authorize.AuthorizeException;
055: import org.dspace.eperson.EPerson;
056:
057: /**
058: * Present the user with a list of not-yet-but-soon-to-be-deleted-epeople.
059: *
060: * @author Alexey Maslov
061: */
062: public class DeleteEPeopleConfirm extends AbstractDSpaceTransformer {
063: /** Language Strings */
064: private static final Message T_dspace_home = message("xmlui.general.dspace_home");
065:
066: private static final Message T_eperson_trail = message("xmlui.administrative.eperson.general.epeople_trail");
067:
068: private static final Message T_title = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.title");
069:
070: private static final Message T_trail = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.trail");
071:
072: private static final Message T_confirm_head = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.confirm_head");
073:
074: private static final Message T_confirm_para = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.confirm_para");
075:
076: private static final Message T_head_id = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.head_id");
077:
078: private static final Message T_head_name = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.head_name");
079:
080: private static final Message T_head_email = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.head_email");
081:
082: private static final Message T_submit_confirm = message("xmlui.administrative.eperson.DeleteEPeopleConfirm.submit_confirm");
083:
084: private static final Message T_submit_cancel = message("xmlui.general.cancel");
085:
086: public void addPageMeta(PageMeta pageMeta) throws WingException {
087: pageMeta.addMetadata("title").addContent(T_title);
088: pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
089: pageMeta.addTrailLink(contextPath + "/admin/epeople",
090: T_eperson_trail);
091: pageMeta.addTrail().addContent(T_trail);
092: }
093:
094: public void addBody(Body body) throws WingException, SQLException,
095: AuthorizeException {
096: // Get all our parameters
097: String idsString = parameters.getParameter("epeopleIDs", null);
098:
099: ArrayList<EPerson> epeople = new ArrayList<EPerson>();
100: for (String id : idsString.split(",")) {
101: EPerson person = EPerson.find(context, Integer.valueOf(id));
102: epeople.add(person);
103: }
104:
105: // DIVISION: epeople-confirm-delete
106: Division deleted = body.addInteractiveDivision(
107: "epeople-confirm-delete", contextPath
108: + "/admin/epeople", Division.METHOD_POST,
109: "primary administrative eperson");
110: deleted.setHead(T_confirm_head);
111: deleted.addPara(T_confirm_para);
112:
113: Table table = deleted.addTable("epeople-confirm-delete",
114: epeople.size() + 1, 1);
115: Row header = table.addRow(Row.ROLE_HEADER);
116: header.addCell().addContent(T_head_id);
117: header.addCell().addContent(T_head_name);
118: header.addCell().addContent(T_head_email);
119:
120: for (EPerson eperson : epeople) {
121: Row row = table.addRow();
122: row.addCell().addContent(eperson.getID());
123: row.addCell().addContent(eperson.getFullName());
124: row.addCell().addContent(eperson.getEmail());
125: }
126: Para buttons = deleted.addPara();
127: buttons.addButton("submit_confirm").setValue(T_submit_confirm);
128: buttons.addButton("submit_cancel").setValue(T_submit_cancel);
129:
130: deleted.addHidden("administrative-continue").setValue(
131: knot.getId());
132: }
133: }
|