public void addBody(Body body) throws WingException, SQLException, AuthorizeException {
    // Get all our parameters
    MetadataSchema[] schemas = MetadataSchema.findAll(context);
    String idsString = parameters.getParameter("fieldIDs", null);

    ArrayList<MetadataField> fields = new ArrayList<MetadataField>();
    for (String id : idsString.split(",")) {
      MetadataField field = MetadataField.find(context, Integer.valueOf(id));
      fields.add(field);
    }

    // DIVISION: metadata-field-move
    Division moved =
        body.addInteractiveDivision(
            "metadata-field-move",
            contextPath + "/admin/metadata-registry",
            Division.METHOD_POST,
            "primary administrative metadata-registry");
    moved.setHead(T_head1);
    moved.addPara(T_para1);

    Table table = moved.addTable("metadata-field-move", fields.size() + 1, 3);
    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCell().addContent(T_column1);
    header.addCell().addContent(T_column2);
    header.addCell().addContent(T_column3);

    for (MetadataField field : fields) {
      String fieldID = String.valueOf(field.getID());
      String fieldEelement = field.getElement();
      String fieldQualifier = field.getQualifier();

      MetadataSchema schema = MetadataSchema.find(context, field.getSchemaID());
      String schemaName = schema.getName();

      String fieldName = schemaName + "." + fieldEelement;
      if (fieldQualifier != null && fieldQualifier.length() > 0) fieldName += "." + fieldQualifier;

      String fieldScopeNote = field.getScopeNote();

      Row row = table.addRow();
      row.addCell().addContent(fieldID);
      row.addCell().addContent(fieldName);
      row.addCell().addContent(fieldScopeNote);
    }

    Row row = table.addRow();
    Cell cell = row.addCell(1, 3);
    cell.addContent(T_para2);
    Select toSchema = cell.addSelect("to_schema");
    for (MetadataSchema schema : schemas) {
      toSchema.addOption(schema.getID(), schema.getNamespace());
    }

    Para buttons = moved.addPara();
    buttons.addButton("submit_move").setValue(T_submit_move);
    buttons.addButton("submit_cancel").setValue(T_submit_cancel);

    moved.addHidden("administrative-continue").setValue(knot.getId());
  }
Ejemplo n.º 2
0
  /**
   * Serialize a single metadata field registry entry to xml
   *
   * @param context DSpace context
   * @param xmlSerializer xml serializer
   * @param mdField DSpace metadata field
   * @throws SAXException if XML error
   * @throws RegistryExportException if export error
   * @throws SQLException if database error
   * @throws IOException if IO error
   */
  private static void saveType(Context context, XMLSerializer xmlSerializer, MetadataField mdField)
      throws SAXException, RegistryExportException, SQLException, IOException {
    // If we haven't been given a field, it's an error
    if (mdField == null) {
      throw new RegistryExportException("no field to export");
    }

    // Get the data from the metadata field
    String schemaName = getSchemaName(context, mdField);
    String element = mdField.getElement();
    String qualifier = mdField.getQualifier();
    String scopeNote = mdField.getScopeNote();

    // We must have a schema and element
    if (schemaName == null || element == null) {
      throw new RegistryExportException("incomplete field information");
    }

    // Output the parent tag
    xmlSerializer.startElement("dc-type", null);

    // Output the schema name
    xmlSerializer.startElement("schema", null);
    xmlSerializer.characters(schemaName.toCharArray(), 0, schemaName.length());
    xmlSerializer.endElement("schema");

    // Output the element
    xmlSerializer.startElement("element", null);
    xmlSerializer.characters(element.toCharArray(), 0, element.length());
    xmlSerializer.endElement("element");

    // Output the qualifier, if present
    if (qualifier != null) {
      xmlSerializer.startElement("qualifier", null);
      xmlSerializer.characters(qualifier.toCharArray(), 0, qualifier.length());
      xmlSerializer.endElement("qualifier");
    } else {
      xmlSerializer.comment("unqualified");
    }

    // Output the scope note, if present
    if (scopeNote != null) {
      xmlSerializer.startElement("scope_note", null);
      xmlSerializer.characters(scopeNote.toCharArray(), 0, scopeNote.length());
      xmlSerializer.endElement("scope_note");
    } else {
      xmlSerializer.comment("no scope note");
    }

    xmlSerializer.endElement("dc-type");
  }