<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
    
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <jsp:directive.page import="edu.ucsb.nceas.metacat.clientview.ClientViewHelper"/>
    <jsp:directive.page import="edu.ucsb.nceas.metacat.clientview.ClientView"/>
    
    <jsp:declaration>
        private ClientViewHelper            clientViewHelper;
    </jsp:declaration>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        	<title>SAEON - South African Environmental Observation Network Repository</title>
        	<link href="saeon.css" rel="stylesheet" type="text/css" />
        </head>
        <body style="background: #FFFFFF;">
            <jsp:useBean id="clientViewBean" scope="session" class="edu.ucsb.nceas.metacat.clientview.ClientView"/>
            <jsp:setProperty name="clientViewBean" property="*"/>
            
            <h2>Delete Data Packages</h2>
            
            <jsp:scriptlet>
                clientViewHelper = ClientViewHelper.clientViewHelperInstance(request);
                clientViewHelper.clientRequest(request, response);
                if (clientViewHelper.isLoggedIn()) {
            </jsp:scriptlet>
            
            <table>
                <tr>
                    <td colspan="3">
                        <h3>Search</h3>
                        <p class="regtext">
                        	Retrieve a list of existing FGDC data packages for a specified scope.
                        </p>	
                        <form name="scopeForm" method="post" action="SaeonDelete.jspx">
                            <input name="returnfield" type="hidden" value="distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr"/>
                            <input name="pathExpr" type="hidden" value="/metadata/distinfo/resdesc"/>
                            <jsp:element name="input">
                                <jsp:attribute name="name">sessionid</jsp:attribute>
                                <jsp:attribute name="type">hidden</jsp:attribute>
                                <jsp:attribute name="value">
                                	<jsp:getProperty name="clientViewBean" property="sessionid"/>
                                </jsp:attribute>
                            </jsp:element>
                            <p class="regtext">
                                <!-- Set the pathValue to the username (the scope) -->
                                <jsp:element name="input">
                                    <jsp:attribute name="name">pathValue</jsp:attribute>
                                    <jsp:attribute name="type">text</jsp:attribute>
                                    <jsp:attribute name="value">
                                    	<jsp:getProperty name="clientViewBean" property="username"/>
                                    </jsp:attribute>
                                    <jsp:attribute name="size">14</jsp:attribute>
                                </jsp:element>
                                <input name="action" value="Scope" type="submit" class="button_login"/>
                            </p>
                        </form>
                        
                    </td>
                </tr>
                
                <jsp:scriptlet>
                    if (clientViewBean.getMessage(ClientView.SELECT_MESSAGE) != null) {
                </jsp:scriptlet>
                 <tr>
                    <td>
                    	<h3>Delete</h3>
                        <p class="regtext">
                            Caution: Removes records from metacat server and, if a metadata Doc Id, any associated Doc Id records.
                        </p>
                    </td>
				</tr>
                <tr>
                    <td>
                        <form name="deleteForm" method="post" action="SaeonDelete.jspx">
                            <jsp:element name="input">
                                <jsp:attribute name="name">sessionid</jsp:attribute>
                                <jsp:attribute name="type">hidden</jsp:attribute>
                                <jsp:attribute name="value">
                                	<jsp:getProperty name="clientViewBean" property="sessionid"/>
                                </jsp:attribute>
                            </jsp:element>
                            <jsp:expression>clientViewBean.getMessage(ClientView.SELECT_MESSAGE)</jsp:expression>
                            
                            <input name="action" type="submit" value="Delete" class="button_login"/>
                        </form>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <p class="regtext">
                            <jsp:scriptlet>if (clientViewBean.getMessage(ClientView.DELETE_MESSAGE) != null) {</jsp:scriptlet>
								<jsp:expression>clientViewBean.getMessage(ClientView.DELETE_MESSAGE)</jsp:expression>
                            <jsp:scriptlet>}</jsp:scriptlet>
                        </p>
                    </td>
                </tr>
                <jsp:scriptlet>
                    }
                </jsp:scriptlet>
            </table>
            
            <jsp:scriptlet>
                } else {
            </jsp:scriptlet>
	            <span class="regtext">
	                You must be logged into your user account before deleting a data set.
	            </span>
            <jsp:scriptlet>
                }
            </jsp:scriptlet>
            
            <p class="regtext">
                <form action="SaeonLogin.jspx">
                    <input name="action" type="submit" value="Back" class="button_login"/>
                </form>
            </p>
            
            <br/>DEBUG<br/>
            action = <jsp:getProperty name="clientViewBean" property="action"/><br/>
            qformat = <jsp:getProperty name="clientViewBean" property="qformat"/><br/>
            anyfield = <jsp:getProperty name="clientViewBean" property="anyfield"/><br/>
            username = <jsp:getProperty name="clientViewBean" property="username"/><br/>
            organization = <jsp:getProperty name="clientViewBean" property="organization"/><br/>
        </body>
    </html>
    
</jsp:root>
