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()); }
List<DCValue> get(Context c, int resourceId, int resourceTypeId, Logger log) throws SQLException { if (metadata == null) { metadata = new ArrayList<DCValue>(); // Get Dublin Core metadata TableRowIterator tri = retrieveMetadata(resourceId, resourceTypeId); if (tri != null) { try { while (tri.hasNext()) { TableRow resultRow = tri.next(); // Get the associated metadata field and schema information int fieldID = resultRow.getIntColumn("metadata_field_id"); MetadataField field = MetadataField.find(c, fieldID); if (field == null) { log.error("Loading item - cannot find metadata field " + fieldID); } else { MetadataSchema schema = MetadataSchema.find(c, field.getSchemaID()); if (schema == null) { log.error( "Loading item - cannot find metadata schema " + field.getSchemaID() + ", field " + fieldID); } else { // Make a DCValue object DCValue dcv = new DCValue(); dcv.element = field.getElement(); dcv.qualifier = field.getQualifier(); dcv.value = resultRow.getStringColumn("text_value"); dcv.language = resultRow.getStringColumn("text_lang"); // dcv.namespace = schema.getNamespace(); dcv.schema = schema.getName(); dcv.authority = resultRow.getStringColumn("authority"); dcv.confidence = resultRow.getIntColumn("confidence"); // Add it to the list metadata.add(dcv); } } } } finally { // close the TableRowIterator to free up resources if (tri != null) { tri.close(); } } } } return metadata; }