001: /*
002: * DeleteMetadataFieldsConfirm.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.registries;
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.content.MetadataField;
056: import org.dspace.content.MetadataSchema;
057:
058: /**
059: * Prompt the user with a list of to-be-deleted metadata fields and
060: * ask the user if they are sure they want them deleted.
061: *
062: * @author Scott phillips
063: */
064: public class DeleteMetadataFieldsConfirm extends
065: AbstractDSpaceTransformer {
066:
067: /** Language Strings */
068: private static final Message T_dspace_home = message("xmlui.general.dspace_home");
069: private static final Message T_submit_delete = message("xmlui.general.delete");
070: private static final Message T_submit_cancel = message("xmlui.general.cancel");
071: private static final Message T_title = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.title");
072: private static final Message T_metadata_registry_trail = message("xmlui.administrative.registries.general.metadata_registry_trail");
073: private static final Message T_trail = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.trail");
074: private static final Message T_head = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.head");
075: private static final Message T_para1 = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.para1");
076: private static final Message T_warning = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.warning");
077: private static final Message T_para2 = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.para2");
078: private static final Message T_column1 = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.column1");
079: private static final Message T_column2 = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.column2");
080: private static final Message T_column3 = message("xmlui.administrative.registries.DeleteMetadataFieldsConfirm.column3");
081:
082: public void addPageMeta(PageMeta pageMeta) throws WingException {
083: pageMeta.addMetadata("title").addContent(T_title);
084: pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
085: pageMeta.addTrailLink(contextPath + "/admin/metadata-registry",
086: T_metadata_registry_trail);
087: pageMeta.addTrail().addContent(T_trail);
088: }
089:
090: public void addBody(Body body) throws WingException, SQLException,
091: AuthorizeException {
092: // Get all our parameters
093: String idsString = parameters.getParameter("fieldIDs", null);
094:
095: ArrayList<MetadataField> fields = new ArrayList<MetadataField>();
096: for (String id : idsString.split(",")) {
097: MetadataField field = MetadataField.find(context, Integer
098: .valueOf(id));
099: fields.add(field);
100: }
101:
102: // DIVISION: metadata-field-confirm-delete
103: Division deleted = body.addInteractiveDivision(
104: "metadata-field-confirm-delete", contextPath
105: + "/admin/metadata-registry",
106: Division.METHOD_POST,
107: "primary administrative metadata-registry");
108: deleted.setHead(T_head);
109: deleted.addPara(T_para1);
110: Para warning = deleted.addPara();
111: warning.addHighlight("bold").addContent(T_warning);
112: warning.addContent(T_para2);
113:
114: Table table = deleted.addTable("field-confirm-delete", fields
115: .size() + 1, 3);
116: Row header = table.addRow(Row.ROLE_HEADER);
117: header.addCell().addContent(T_column1);
118: header.addCell().addContent(T_column2);
119: header.addCell().addContent(T_column3);
120:
121: for (MetadataField field : fields) {
122: if (field == null)
123: continue;
124:
125: String fieldID = String.valueOf(field.getFieldID());
126: String fieldEelement = field.getElement();
127: String fieldQualifier = field.getQualifier();
128:
129: MetadataSchema schema = MetadataSchema.find(context, field
130: .getSchemaID());
131: String schemaName = schema.getName();
132:
133: String fieldName = schemaName + "." + fieldEelement;
134: if (fieldQualifier != null && fieldQualifier.length() > 0)
135: fieldName += "." + fieldQualifier;
136:
137: String fieldScopeNote = field.getScopeNote();
138:
139: Row row = table.addRow();
140: row.addCell().addContent(fieldID);
141: row.addCell().addContent(fieldName);
142: row.addCell().addContent(fieldScopeNote);
143: }
144: Para buttons = deleted.addPara();
145: buttons.addButton("submit_confirm").setValue(T_submit_delete);
146: buttons.addButton("submit_cancel").setValue(T_submit_cancel);
147:
148: deleted.addHidden("administrative-continue").setValue(
149: knot.getId());
150: }
151: }
|