Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/Mat/DescribeMessager.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/Mat/DescribeMessager.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/Mat/DescribeMessager.java	(revision 17184)
@@ -0,0 +1,344 @@
+package Mat;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.greenstone.gsdl3.core.MessageRouter;
+import org.greenstone.gsdl3.util.DBInfo;
+import org.greenstone.gsdl3.util.GDBMWrapper;
+import org.greenstone.gsdl3.util.GlobalProperties;
+import org.greenstone.gsdl3.util.GSFile;
+import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.XMLConverter;
+
+
+
+public class DescribeMessager {
+	protected String site_name = "localsite";
+	private GDBMWrapper gdbm_src = new GDBMWrapper();
+	/** message router object to pass requests messages to and which 
+	 * will process them.*/
+	protected MessageRouter mr = null;
+	
+	/** container Document to create XML Nodes */
+	protected Document doc=null;
+	/** a converter class to parse XML and create Docs */
+	protected XMLConverter converter=null;
+	
+	protected final static String mrSubsetOptions = //messageRouter 
+		"collectionList serviceClusterList serviceList siteList"; 
+	protected final static String csSubsetOptions = //collections and serviceClusters 
+		"metadataList serviceList displayItemList";
+	protected final static String serviceSubsetOptions = //services
+		"paramList displayItemList";
+	final int MESSAGEROUTER = 1, COLLECTION = 2, 
+		SERVICECLUSTER = 3, SERVICE = 4;
+	
+	
+	public DescribeMessager() {
+	    String gsdl3_home = GlobalProperties.getGSDL3Home();
+		if (gsdl3_home == null || gsdl3_home.equals("")) {
+		    System.err.println("Couldn't access GSDL3Home from GlobalProperties.getGSDL3HOME, can't initialize the SOAP Server.");
+		    return;
+		}
+		
+		String site_home = GSFile.siteHome(gsdl3_home, this.site_name);
+		
+		File site_file = new File(site_home);
+		if (!site_file.isDirectory()) {
+		    System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialize the SOAP Server.");
+		    return;
+		} 
+		this.converter = new XMLConverter();
+		this.doc = this.converter.newDOM();
+		
+		mr = new MessageRouter();
+		mr.setSiteName(this.site_name);
+		mr.configure();
+    }
+	
+	//Describe messages sent to MESSAGEROUTER
+	//By default: sends a describe request message to the MessageRouter, with
+	//lang=en (and all MessageRouter subsetOptions set).
+	public String describe() 
+	{
+		//describe(to=MR, lang=en, no subsetOptions, from valid mrSubsetOptions)
+		return describe("", "", "", mrSubsetOptions);
+	}
+	
+	public String describe(String subsetOption) 
+	{
+		return describe("", "", subsetOption, mrSubsetOptions);
+	}
+	
+	public String describe(String lang, String subsetOption) 
+	{
+		return describe("", lang, subsetOption, mrSubsetOptions);
+	}
+	
+	
+	//Describe messages sent to COLLECTIONS and SERVICERACKS
+	public String describeServiceRack(String toSC, String lang, 
+			String subsetOption)
+	{
+		return describe(toSC, lang, subsetOption, csSubsetOptions);
+	}
+	
+	
+	public String describeCollection(String toColl, String lang, 
+			String subsetOption)
+	{
+		return describe(toColl, lang, subsetOption, csSubsetOptions);
+	}
+	
+	//Describe Messages sent to Services (or Collection/Services) 
+	public String describeCollService(String toColl, String toService, 
+			String lang, String subsetOption) {
+		/*String message =  
+			"<message><request lang=\"en\" to=\"gs2mgppdemo/FieldQuery\" type=\"describe\" /></message>";
+				
+			String response = mr.process(message);
+			System.out.println("Response to: " + message + ":\n");
+			System.out.println(response);
+		*/	
+		return describe(toColl + "/" + toService, 
+				lang, subsetOption, serviceSubsetOptions);
+	}
+	
+	public String describeService(
+			String toService, String lang, String subsetOption) 
+	{
+		return describe(toService, lang, subsetOption, serviceSubsetOptions);
+	}
+	
+	//GET POSSIBLE SUBSET OPTIONS FOR THE VARIOUS RECEIVERS (MessageRouter,
+	//Services, ServiceRack/Collections
+	
+	//Subset options that can be specified when asking the messageRouter to
+	//describe itself
+	public String getMessageRouterSubsetOptions() {
+		return mrSubsetOptions;
+	}
+	
+	//Possible subset options for ServiceClusters and Collections
+	public String getCSSubsetOptions() {
+		return csSubsetOptions;
+	}
+	
+	//Possible subset options for services
+	public String getServiceSubsetOptions() {
+		return serviceSubsetOptions;
+	}
+	
+	//If public, this method would give full access: a describe message that 
+	//lets the user specify all the details of who the receiver is, and what 
+	//details are requested.
+	
+	/*
+	protected String describe(String to, String lang, 
+			String subsetOption, String validSubsetOptions)
+	{
+		//Create message element: <message></message>
+		Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		//<message><request lang="en" to="" type="describe" uid="" /></message>
+		Element request = GSXML.createBasicRequest(
+				this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, "");
+		
+		//Check if only a subset of this Module Interface's data is asked
+		//to be described
+		if(subsetOption != "") {
+			//Now deal with the value for subset param:
+			//only deal with valid params for subset of to-ModuleInterface
+			if(validSubsetOptions.indexOf(subsetOption) == -1)
+				return "Invalid List to be described. Choose one of:\n"
+					+ validSubsetOptions;
+			
+			//else, append <paramList />
+			Element param_list = this.doc.createElement(
+					GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+			//append <param name="subset" value=paramValue />
+			//createParam(Document, name, value); 
+			//Name needs to be "subset", but this can be either GSXML.SUBSET_PARAM
+			//or GSXML.SYSTEM_SUBSET_ATT. It's the first one probably.
+			param_list.appendChild(GSXML.createParameter(
+							this.doc, GSXML.SUBSET_PARAM, subsetOption));
+			request.appendChild(param_list);
+		}
+		message.appendChild(request);
+		
+		//System.out.println(this.converter.getPrettyString(message));
+		
+		//Let the messagerouter process the request message and get the response
+		Element response = mr.process(message.getFirstChild());
+		//String response = mr.process(this.converter.getPrettyString(message));
+		//this.converter.getPrettyString(arg0);
+		//mr.p
+		//Return it as a String formatted for display
+		System.out.println(this.converter.getPrettyString(response));
+		
+		return null;
+		//return this.converter.getPrettyString(response);
+		//return this.converter.getString(response);
+		//return mr.process(this.converter.getString(message));
+	}
+	*/
+	
+	
+	
+	protected String describe(String to, String lang, 
+			String subsetOption, String validSubsetOptions)
+	{
+		//Create message element: <message></message>
+		Node message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		//<message><request lang="en" to="" type="describe" uid="" /></message>
+		Node request = GSXML.createBasicRequest(
+				this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, "");
+		
+		//Check if only a subset of this Module Interface's data is asked
+		//to be described
+		if(subsetOption != "") {
+			//Now deal with the value for subset param:
+			//only deal with valid params for subset of to-ModuleInterface
+			if(validSubsetOptions.indexOf(subsetOption) == -1)
+				return "Invalid List to be described. Choose one of:\n"
+					+ validSubsetOptions;
+			
+			//else, append <paramList />
+			Node param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+			//append <param name="subset" value=paramValue />
+			//createParam(Document, name, value); 
+			//Name needs to be "subset", but this can be either GSXML.SUBSET_PARAM
+			//or GSXML.SYSTEM_SUBSET_ATT. It's the first one probably.
+			param_list.appendChild(GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, subsetOption));
+			request.appendChild(param_list);
+		}
+		message.appendChild(request);
+		
+		//System.out.println(this.converter.getPrettyString(message));
+		
+		//Let the messagerouter process the request message and get the response
+		Node response = mr.process(message);
+		//String response = mr.process(this.converter.getPrettyString(message));
+		//this.converter.getPrettyString(arg0);
+		//mr.p
+		//Return it as a String formatted for display
+		Element res = (Element) response;
+		System.out.println(this.converter.getPrettyString(res));
+		System.out.println("break1");
+		
+    	String gsdl3_home = GlobalProperties.getGSDL3Home();
+    	if (gsdl3_home == null || gsdl3_home.equals("")) {
+    	    System.err.println("Couldn't access GSDL3Home from GlobalProperties.getGSDL3HOME, can't initialize the SOAP Server.");
+    	}
+    	
+    	String site_home = GSFile.siteHome(gsdl3_home, this.site_name);
+		String gdbm = GSFile.collectionDatabaseFile(site_home,"sampleco","sampleco","gdbm");
+
+		/*
+		try{
+		System.out.println("break2.1");
+		//System.out.println(this.gdbm_src.openDatabase("gs2mgppdemo",GDBMWrapper.READ));
+		}catch (Exception ex) {ex.printStackTrace();}
+		*/
+		//System.out.println(gdbm);
+		System.out.println("break2.2");
+		if (!this.gdbm_src.openDatabase(gdbm,GDBMWrapper.READ)) {
+		//if(false){
+			System.out.println("break31");
+		    System.out.println("Could not open GDBM database!");
+		    
+		}
+		
+		else{
+			System.out.println("break32");
+
+			
+		    String info = this.gdbm_src.getValue("browselist");
+		
+		    if (info == null) {
+		    	System.out.println("cannot locate the list");
+		    }
+		    else{
+			
+			if (info == null) {
+				System.out.println("the db does not contain any info");
+			}
+		    
+			
+			ArrayList children = new ArrayList();
+			StringTokenizer st = new StringTokenizer(info, ";");
+			//StringTokenizer st = new StringTokenizer(st2, ";");
+			//System.out.println(info);
+
+			while (st.hasMoreTokens()) {
+				String part = st.nextToken(";");
+				//System.out.println("..."+part+".....1");
+				
+				
+				if(part.contains("<contains>")){
+					part = part.replace("<contains>", "");
+				}
+				else if(part.contains("<thistype>")){
+					//System.out.println("here");
+					int location = part.indexOf("<thistype>");
+					part = part.substring(0,location-1);
+				}
+				System.out.println("..."+part+".....2");
+			    //String child_id = st.nextToken().replaceAll("\"", node_id);
+			    //children.add(child_id);
+			}
+			
+			gdbm_src.closeDatabase();
+			System.out.println("start..................");
+			//System.out.println(info);
+			System.out.println("end..................");
+			//parseMetadata(children,"all");
+			//TotalDoc = children.size();
+			//System.out.println("Total Doc:"+TotalDoc);
+			//status = true;
+			//Display();
+		    //}
+		    }
+		}
+		
+		return "";
+		//return this.converter.getPrettyString(response);
+		//return this.converter.getString(response);
+		//return mr.process(this.converter.getString(message));
+	}
+	//UNUSED:
+	public static String describeExampleResponse() {
+		XMLConverter converter = new XMLConverter();
+		Document doc = converter.getDOM("SampleServiceResponse.xml");
+		return converter.getPrettyString(doc);
+	}
+
+	
+	
+	public static void main(String[] args) {
+		DescribeMessager dm = new DescribeMessager();
+		String response[] = new String[3];
+		
+		response[0] = dm.describe();
+		//response[1] = dm.describeMessageRouter("", "serviceList"); //""->lang=en
+		response[1] = dm.describeService("TextQuery", "en", "");
+		response[2] = dm.describeCollection("gs2mgdemo", "en", "metadataList");
+		//response[3] = dm.describeCollection("gberg", "en", "serviceList");
+		//response[4] = dm.describeService("DocumentMetadataRetrieve", "", "");
+		//response[3] = dm.describeService("DocumentContentRetrieve", "en", "");
+
+		//French doesn't seem to have any effect
+		//response[3] = dm.sendDescribe("", "fr"); 
+		/*
+		for(int i = 0; i < response.length; i++)
+			System.out.println(
+					(response[i]==null) ? "no response" : response[i]);
+		System.exit(0);
+		*/
+	}
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteConstraints.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteConstraints.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteConstraints.java	(revision 17184)
@@ -0,0 +1,116 @@
+/*
+ *                 Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+//package org.netbeans.lib.awtextra;
+
+package org.greenstone3.ms;
+
+import java.awt.Dimension;
+import java.awt.Point;
+
+/** An object that encapsulates position and (optionally) size for
+ * Absolute positioning of components.
+ *
+ * @see AbsoluteLayout
+ * @version 1.01, Aug 19, 1998
+ */
+public class AbsoluteConstraints implements java.io.Serializable {
+    /** generated Serialized Version UID */
+    static final long serialVersionUID = 5261460716622152494L;
+
+    /** The X position of the component */
+    public int x;
+    /** The Y position of the component */
+    public int y;
+    /** The width of the component or -1 if the component's preferred width should be used */
+    public int width = -1;
+    /** The height of the component or -1 if the component's preferred height should be used */
+    public int height = -1;
+
+    /** Creates a new AbsoluteConstraints for specified position.
+     * @param pos The position to be represented by this AbsoluteConstraints
+     */
+    public AbsoluteConstraints(Point pos) {
+        this(pos.x, pos.y);
+    }
+
+    /** Creates a new AbsoluteConstraints for specified position.
+     * @param x The X position to be represented by this AbsoluteConstraints
+     * @param y The Y position to be represented by this AbsoluteConstraints
+     */
+    public AbsoluteConstraints(int x, int y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** Creates a new AbsoluteConstraints for specified position and size.
+     * @param pos  The position to be represented by this AbsoluteConstraints
+     * @param size The size to be represented by this AbsoluteConstraints or null
+     *             if the component's preferred size should be used
+     */
+    public AbsoluteConstraints(Point pos, Dimension size) {
+        this.x = pos.x;
+        this.y = pos.y;
+        if (size != null) {
+            this.width = size.width;
+            this.height = size.height;
+        }
+    }
+
+    /** Creates a new AbsoluteConstraints for specified position and size.
+     * @param x      The X position to be represented by this AbsoluteConstraints
+     * @param y      The Y position to be represented by this AbsoluteConstraints
+     * @param width  The width to be represented by this AbsoluteConstraints or -1 if the
+     *               component's preferred width should be used
+     * @param height The height to be represented by this AbsoluteConstraints or -1 if the
+     *               component's preferred height should be used
+     */
+    public AbsoluteConstraints(int x, int y, int width, int height) {
+        this.x = x;
+        this.y = y;
+        this.width = width;
+        this.height = height;
+    }
+
+    /** @return The X position represented by this AbsoluteConstraints */
+    public int getX() {
+        return x;
+    }
+
+    /** @return The Y position represented by this AbsoluteConstraints */
+    public int getY() {
+        return y;
+    }
+
+    /** @return The width represented by this AbsoluteConstraints or -1 if the
+     * component's preferred width should be used
+     */
+    public int getWidth() {
+        return width;
+    }
+
+    /** @return The height represented by this AbsoluteConstraints or -1 if the
+     * component's preferred height should be used
+     */
+    public int getHeight() {
+        return height;
+    }
+
+    public String toString() {
+        return super.toString() + " [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]";
+    }
+
+}
+
+
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteLayout.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteLayout.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteLayout.java	(revision 17184)
@@ -0,0 +1,166 @@
+/*
+ *                 Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+//package org.netbeans.lib.awtextra;
+package org.greenstone3.ms;
+
+import java.awt.*;
+
+/** AbsoluteLayout is a LayoutManager that works as a replacement for "null" layout to
+ * allow placement of components in absolute positions.
+ *
+ * @see AbsoluteConstraints
+ * @version 1.01, Aug 19, 1998
+ */
+public class AbsoluteLayout implements LayoutManager2, java.io.Serializable {
+    /** generated Serialized Version UID */
+    static final long serialVersionUID = -1919857869177070440L;
+
+    /** Adds the specified component with the specified name to
+     * the layout.
+     * @param name the component name
+     * @param comp the component to be added
+     */
+    public void addLayoutComponent(String name, Component comp) {
+        throw new IllegalArgumentException();
+    }
+
+    /** Removes the specified component from the layout.
+     * @param comp the component to be removed
+     */
+    public void removeLayoutComponent(Component comp) {
+        constraints.remove(comp);
+    }
+
+    /** Calculates the preferred dimension for the specified
+     * panel given the components in the specified parent container.
+     * @param parent the component to be laid out
+     *
+     * @see #minimumLayoutSize
+     */
+    public Dimension preferredLayoutSize(Container parent) {
+        int maxWidth = 0;
+        int maxHeight = 0;
+        for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();) {
+            Component comp = (Component) e.nextElement();
+            AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp);
+            Dimension size = comp.getPreferredSize();
+
+            int width = ac.getWidth();
+            if (width == -1) width = size.width;
+            int height = ac.getHeight();
+            if (height == -1) height = size.height;
+
+            if (ac.x + width > maxWidth)
+                maxWidth = ac.x + width;
+            if (ac.y + height > maxHeight)
+                maxHeight = ac.y + height;
+        }
+        return new Dimension(maxWidth, maxHeight);
+    }
+
+    /** Calculates the minimum dimension for the specified
+     * panel given the components in the specified parent container.
+     * @param parent the component to be laid out
+     * @see #preferredLayoutSize
+     */
+    public Dimension minimumLayoutSize(Container parent) {
+        int maxWidth = 0;
+        int maxHeight = 0;
+        for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();) {
+            Component comp = (Component) e.nextElement();
+            AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp);
+
+            Dimension size = comp.getMinimumSize();
+
+            int width = ac.getWidth();
+            if (width == -1) width = size.width;
+            int height = ac.getHeight();
+            if (height == -1) height = size.height;
+
+            if (ac.x + width > maxWidth)
+                maxWidth = ac.x + width;
+            if (ac.y + height > maxHeight)
+                maxHeight = ac.y + height;
+        }
+        return new Dimension(maxWidth, maxHeight);
+    }
+
+    /** Lays out the container in the specified panel.
+     * @param parent the component which needs to be laid out
+     */
+    public void layoutContainer(Container parent) {
+        for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();) {
+            Component comp = (Component) e.nextElement();
+            AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp);
+            Dimension size = comp.getPreferredSize();
+            int width = ac.getWidth();
+            if (width == -1) width = size.width;
+            int height = ac.getHeight();
+            if (height == -1) height = size.height;
+
+            comp.setBounds(ac.x, ac.y, width, height);
+        }
+    }
+
+    /** Adds the specified component to the layout, using the specified
+     * constraint object.
+     * @param comp the component to be added
+     * @param constr  where/how the component is added to the layout.
+     */
+    public void addLayoutComponent(Component comp, Object constr) {
+        if (!(constr instanceof AbsoluteConstraints))
+            throw new IllegalArgumentException();
+        constraints.put(comp, constr);
+    }
+
+    /** Returns the maximum size of this component.
+     * @see java.awt.Component#getMinimumSize()
+     * @see java.awt.Component#getPreferredSize()
+     * @see LayoutManager
+     */
+    public Dimension maximumLayoutSize(Container target) {
+        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+    }
+
+    /** Returns the alignment along the x axis.  This specifies how
+     * the component would like to be aligned relative to other
+     * components.  The value should be a number between 0 and 1
+     * where 0 represents alignment along the origin, 1 is aligned
+     * the furthest away from the origin, 0.5 is centered, etc.
+     */
+    public float getLayoutAlignmentX(Container target) {
+        return 0;
+    }
+
+    /** Returns the alignment along the y axis.  This specifies how
+     * the component would like to be aligned relative to other
+     * components.  The value should be a number between 0 and 1
+     * where 0 represents alignment along the origin, 1 is aligned
+     * the furthest away from the origin, 0.5 is centered, etc.
+     */
+    public float getLayoutAlignmentY(Container target) {
+        return 0;
+    }
+
+    /** Invalidates the layout, indicating that if the layout manager
+     * has cached information it should be discarded.
+     */
+    public void invalidateLayout(Container target) {
+    }
+
+
+    /** A mapping <Component, AbsoluteConstraints> */
+    protected java.util.Hashtable constraints = new java.util.Hashtable();
+}
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/CursorController.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/CursorController.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/CursorController.java	(revision 17184)
@@ -0,0 +1,28 @@
+package org.greenstone3.ms;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public final class CursorController {
+    
+    public final static Cursor busyCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
+    public final static Cursor defaultCursor = Cursor.getDefaultCursor();
+    
+    private CursorController() {}
+    
+    public static ActionListener createListener(final Component component, final ActionListener mainActionListener) {
+	ActionListener actionListener = new ActionListener() {
+		public void actionPerformed(ActionEvent ae) {
+		    try {
+			component.setCursor(busyCursor);
+			mainActionListener.actionPerformed(ae);
+		    } finally {
+			component.setCursor(defaultCursor);
+		    }
+		}
+	    };
+	return actionListener;
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DataMaker.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DataMaker.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DataMaker.java	(revision 17184)
@@ -0,0 +1,834 @@
+package org.greenstone3.ms;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.math.BigDecimal;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.greenstone.gsdl3.core.MessageRouter;
+import org.greenstone.gsdl3.util.XMLConverter;
+
+public class DataMaker {
+    
+    MetadataStats  ms;
+    ArrayList nameList;
+    private int Mode;
+    private int TotalDoc; 
+    private String path;
+    
+    protected Document doc=null;
+    protected MessageRouter mr = null;
+    protected XMLConverter converter=null;
+    private ArrayList removedID = new ArrayList();
+    private HashMap elementMap = new HashMap();
+    private static final int DEF_DIV_SCALE = 10;
+    
+    public DataMaker(MetadataStats arg1){
+	ms = arg1;
+	nameList = arg1.metadataNameList;
+	path = arg1.myNewDir;
+	setTotalDocNumber();
+    }
+    
+    
+    private Element getRootNode(String core_element){
+	
+    	if(elementMap.containsKey(core_element)){
+    		return (Element)elementMap.get(core_element);
+    	}
+	try{
+	    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+	    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+	    Document doc = docBuilder.newDocument();
+	    doc = docBuilder.parse (new File(path+"/"+core_element+".xml"));
+	    Element rootNode = doc.getDocumentElement();
+	    //elementMap.put(core_element, rootNode);
+	    return rootNode;   
+    	}catch (Exception e) {
+    	    e.printStackTrace();
+    	    return null;
+    	}
+    }
+    
+    
+    public void setTotalDocNumber(){
+    	Element ex = getRootNode("archivedir");
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	TotalDoc = listOfFrequency.getLength();
+    }
+    
+    public int getTotalElementUsed(){
+	
+	int totalNumber = 0;
+	
+	for(int i = 0 ; i<nameList.size(); i++){
+	    
+	    Element ex = getRootNode((String)nameList.get(i));
+	    NodeList listOfFrequency = ex.getElementsByTagName("Frequency");
+	
+	    for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    	Node FrequencyNode = listOfFrequency.item(s);
+	    	NodeList textFNList = FrequencyNode.getChildNodes();
+	    	String TextNode = textFNList.item(0).getNodeValue();
+	    	totalNumber = totalNumber + Integer.parseInt(TextNode);
+	    }
+	}
+	return totalNumber;
+    }
+      
+    public int getFrequency(String name){
+	
+        int totalNumber = 0;
+      	
+        Element ex = getRootNode(name);
+      	NodeList listOfFrequency = ex.getElementsByTagName("Frequency");
+      	if(listOfFrequency.getLength()==0){return 0;}
+      	
+	for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    Node FrequencyNode = listOfFrequency.item(s);
+	    NodeList textFNList = FrequencyNode.getChildNodes();
+	    String TextNode = textFNList.item(0).getNodeValue();
+	    int x = Integer.parseInt(TextNode);
+	    totalNumber = totalNumber + x;
+        }
+	return totalNumber;
+    }
+    
+    public int getDistinctNumber(String name){
+	
+        ArrayList alist = new ArrayList();
+      	Element ex = getRootNode(name);
+      	NodeList listOfFrequency = ex.getElementsByTagName("ActualValue");
+      	
+	if(listOfFrequency.getLength()==0){
+	    return 0;
+	}
+        
+	for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    Node ActualValueNode = listOfFrequency.item(s);
+	    NodeList textFNList = ActualValueNode.getChildNodes();
+	    String TextNode = textFNList.item(0).getNodeValue();
+	    
+	    if(!alist.contains(TextNode) && !TextNode.equals(" ")){
+		alist.add(TextNode);
+	    }
+        }
+	return alist.size();
+    }
+    
+    public int getDocumentUsedElement(String core_element){
+    
+        int totalNumber = 0;
+      	Element ex = getRootNode(core_element);
+      	NodeList listOfFrequency = ex.getElementsByTagName("Frequency");
+    	for(int s=0; s<listOfFrequency.getLength() ; s++){
+      		totalNumber++;
+        }
+	return totalNumber;
+    }
+       
+    // for all elements
+    public double Mean(String core_element){
+    	
+	int due = getDocumentUsedElement(core_element);
+	
+    	if(due==0 || TotalDoc==0){return 0;}
+    	Double d1 = new Double(due);
+    	Double d2 = new Double(TotalDoc);
+    	Double result = div(d1,d2);
+    	result = mul(result, new Double(100));
+    	return round(result.doubleValue(),1);
+    }
+    
+    public int getMinRange(String core_element){
+	
+      	Element ex = getRootNode(core_element);
+      	NodeList listOfFrequency = ex.getElementsByTagName("Frequency");
+      	
+        if(listOfFrequency.getLength()==0){return 0;}
+        
+    	Node FrequencyNode = listOfFrequency.item(0);
+    	NodeList textFNList = FrequencyNode.getChildNodes();
+    	String TextNode = textFNList.item(0).getNodeValue();
+        int minNumber = 0;
+        
+        if(listOfFrequency.getLength()==TotalDoc){
+	    minNumber = Integer.parseInt(TextNode);
+        }
+        
+        else {
+	    minNumber = 0;
+        }
+        
+        for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    FrequencyNode = listOfFrequency.item(s);
+	    textFNList = FrequencyNode.getChildNodes();
+	    TextNode = textFNList.item(0).getNodeValue();
+	    int x = Integer.parseInt(TextNode);
+	    if(x<minNumber){minNumber=x;}
+        }
+	return minNumber;
+    }
+    
+    public int getMaxRange(String core_element){
+	
+      	Element ex = getRootNode(core_element);
+      	NodeList listOfFrequency = ex.getElementsByTagName("Frequency");
+        if(listOfFrequency.getLength()==0){return 0;}
+    	Node FrequencyNode = listOfFrequency.item(0);
+    	NodeList textFNList = FrequencyNode.getChildNodes();
+    	String TextNode = textFNList.item(0).getNodeValue();
+        int maxNumber = 0;
+        
+        for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    FrequencyNode = listOfFrequency.item(s);
+	    textFNList = FrequencyNode.getChildNodes();
+	    TextNode = textFNList.item(0).getNodeValue();
+	    int x = Integer.parseInt(TextNode);
+	    if(x>maxNumber){maxNumber=x;}
+        }
+	return maxNumber;
+    }
+    
+    public int getMode(String core_element){
+	
+    	Element ex = getRootNode(core_element);
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	if(listOfFrequency.getLength()==0){Mode = 0; return 0;}
+    	ArrayList alist = new ArrayList();
+    	String[] idsx = getDocumentIDs(core_element);
+    	
+	for(int i = 0; i<idsx.length; i++){
+	    alist.add(idsx[i]);
+    	}
+    	int[] list = new int[TotalDoc];
+    	
+	for(int i = 0; i<list.length; i++){
+	    list[i] = 0;
+    	}
+	
+    	for(int s=0; s< listOfFrequency.getLength() ; s++){
+	    Node docNode = listOfFrequency.item(s);
+	    NamedNodeMap NodeIDMap = docNode.getAttributes();
+	    Node DocNodeID = NodeIDMap.item(0);
+	    String DocID = DocNodeID.getNodeValue();
+	    Element xNode = (Element)docNode;
+	    int location = alist.indexOf(DocID);
+	    NodeList xList = xNode.getElementsByTagName("Frequency");
+	    int fre = Integer.parseInt(xList.item(0).getChildNodes().item(0).getNodeValue());
+	    list[location] = fre;
+    	}
+    	
+        Arrays.sort(list);
+	
+	int max_idx = 0; // Index of the maximum count
+	int max_cnt = 0;
+	int count = 0;
+	
+	for ( int i = 0; i <list.length; i++) {
+	    count = 0;
+	    for ( int j = 0; j < list.length; j++) {
+		if (list[i] == list[j]) {
+		    count++;
+		}
+	    }
+	    if (count > max_cnt) {
+		max_cnt = count;
+		max_idx = i;
+	    }	
+	}
+	Mode = list [max_idx];
+	return list [max_idx];
+
+    }
+    
+    public double ModeFrequency(String core_element){
+	
+    	Element ex = getRootNode(core_element);
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	if(listOfFrequency.getLength()==0){ return 100;}
+    	ArrayList alist = new ArrayList();
+    	String[] idsx = getDocumentIDs(core_element);
+    	
+	for(int i = 0; i<idsx.length; i++){
+	    alist.add(idsx[i]);
+    	}
+	
+    	int[] list = new int[TotalDoc];
+    	
+	for(int i = 0; i<list.length; i++){
+	    list[i] = 0;
+    	}
+    	
+    	int length = alist.size();
+    	int counter = 0;
+    	
+    	for(int s=0; s< listOfFrequency.getLength() ; s++){
+	    Node docNode = listOfFrequency.item(s);
+	    NamedNodeMap NodeIDMap = docNode.getAttributes();
+	    Node DocNodeID = NodeIDMap.item(0);
+	    String DocID = DocNodeID.getNodeValue();
+	    Element xNode = (Element)docNode;
+	    int location = alist.indexOf(DocID);
+	    NodeList xList = xNode.getElementsByTagName("Frequency");
+	    int fre = Integer.parseInt(xList.item(0).getChildNodes().item(0).getNodeValue());
+	    list[location] = fre;
+    	}
+	
+    	for(int i =0; i<list.length; i++){
+	    if(list[i]==Mode){counter++;}
+    	}
+
+        Double result = div(new Double(counter), new Double(length));
+        result = mul(result ,new Double (100));
+        return round(result.doubleValue(),1);
+    }
+    
+    public double Median(String core_element){
+	   	
+    	Element ex = getRootNode(core_element);
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+  
+    	ArrayList alist = new ArrayList();
+    	String[] idsx = getDocumentIDs(core_element);
+
+    	for(int i = 0; i<idsx.length; i++){
+	    alist.add(idsx[i]);
+    	}
+
+    	int[] list = new int[TotalDoc];
+
+    	for(int i = 0; i<list.length; i++){
+	    list[i] = 0;
+    	}
+    	
+    	for(int s=0; s< listOfFrequency.getLength() ; s++){
+	    Node docNode = listOfFrequency.item(s);
+	    NamedNodeMap NodeIDMap = docNode.getAttributes();
+	    Node DocNodeID = NodeIDMap.item(0);
+	    String DocID = DocNodeID.getNodeValue();
+	    Element xNode = (Element)docNode;
+	    int location = alist.indexOf(DocID);
+	    NodeList xList = xNode.getElementsByTagName("Frequency");
+	    int fre = Integer.parseInt(xList.item(0).getChildNodes().item(0).getNodeValue());
+	    list[location] = fre;
+    	}
+    	      	
+        int length = alist.size();
+      	int middle = length/2 -1;
+      	
+        Arrays.sort(list);
+	
+	if(length % 2 == 1){
+	    middle = middle + 1;
+	    return list[middle];
+	}
+	
+	else{
+	    return  round((double)(list[middle]+list[middle+1])/2,1);
+	}
+    }
+        
+    // for all elements
+    public double Average(String core_element){
+    	
+    	int t1 = getFrequency(core_element);
+    	int t2 = getDocumentUsedElement(core_element);
+    	if(t1==0 || t2==0){return 0;}
+    	Double result = div(new Double(t1),new Double(t2));
+    	return	round(result.doubleValue(),1);
+    }
+    
+    public Object[][] AllInformation(){
+    	
+	int rows = nameList.size();
+    	int cols = 11;
+    	int y = 0;
+
+    	Object[][] info = new Object[rows][cols];
+    	String[] list = new String[rows];
+    	
+	for(int i = 0 ; i < list.length; i++){
+	    list[i] = nameList.get(i).toString();
+    	}
+	
+    	Arrays.sort(list);
+    	
+    	for(int iu = 0; iu<list.length; iu++){ 
+    	    String xi = list[iu];
+	    info[y][0] = xi ;
+	    info[y][1] = new Integer(getFrequency(xi));
+	    info[y][2] = new Integer(getDocumentUsedElement(xi));
+	    info[y][3] = new Double(Mean(xi));
+	    info[y][4] = new Double(Median(xi));
+	    info[y][5] = new Integer(getDistinctNumber(xi));
+	    info[y][6] = new Integer(getMinRange(xi));
+	    info[y][7] = new Integer(getMaxRange(xi));
+	    info[y][8] = new Double(Average(xi));
+	    info[y][9] = new Integer(getMode(xi));
+	    info[y][10] = ModeFrequency(xi)+"%";
+	    y++;
+	}
+    	return info;
+    }
+    
+    public String[] getSortList(String core_element,String sort){
+	
+    	if(sort.equals("ASCII")){
+    		HashMap hp = getDistinctValueMap (core_element);
+    		String[] temp = new String[hp.size()];
+    		int counter = 0;
+    		Set s = hp.keySet();
+    		Iterator i = s.iterator();
+
+    		while(i.hasNext()){
+    			temp[counter] = (String)i.next();
+    			counter++;
+    		}
+	    
+    		Arrays.sort(temp);
+    		return temp;
+    	}
+	
+    	else{
+    		Map m = getDistinctValueMap (core_element);
+    		ArrayList outputList = sortMap(m);
+    		String[] temp = new String[outputList.size()];
+	    
+    		for(int i = 0; i< outputList.size(); i++){
+    			Map.Entry entry = (Map.Entry) outputList.get(i);
+    			temp[i] = (String) entry.getKey();
+    		}
+    		
+	    return temp;
+    	}
+	
+    }
+
+    
+    /*
+     * Actually, we can directly access to "ActualValue" node instead of document node
+     */
+    
+    public HashMap getDistinctValueMap(String core_element){
+    	
+	Element ex = getRootNode(core_element);
+    	HashMap hp = new HashMap();
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	
+	for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    Node docNode = listOfFrequency.item(s);
+	    Element docElement = (Element)docNode;
+	    NodeList valueList = docElement.getElementsByTagName("ActualValue");
+	    
+	    for(int y = 0; y<valueList.getLength(); y++){
+		Element valueElement = (Element)valueList.item(y);
+		NodeList textFNList = valueElement.getChildNodes();
+		String text = ((Node)textFNList.item(0)).getNodeValue();
+		
+		if(!text.equals(" ")){
+		    if(hp.containsKey(text)){
+			Integer i = (Integer)hp.get(text);
+			int number = i.intValue();
+			number++;
+			hp.put(text,new Integer(number));
+		    }
+		    else{
+			Integer i = new Integer(1);
+			hp.put(text, i);
+		    }
+		}
+	    }
+    	}               
+    	return hp;
+    }
+    
+    public HashMap getDocFrequencyMap(String core_element){
+    	
+	Element ex = getRootNode(core_element);
+    	HashMap hp = new HashMap();
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	
+	for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    
+	    Node docNode = listOfFrequency.item(s);  
+	    NamedNodeMap NodeMap = docNode.getAttributes();
+	    Node AttributeNode = NodeMap.item(0);
+	    String att_name = AttributeNode.getNodeValue();
+	    
+	    Element docElement = (Element)docNode;
+	    NodeList valueList = docElement.getElementsByTagName("Frequency");
+	    Element frequencyElement = (Element)valueList.item(0);
+	    NodeList textFNList = frequencyElement.getChildNodes();
+	    String text = ((Node)textFNList.item(0)).getNodeValue();
+	    Integer i = new Integer(Integer.parseInt(text));
+	    hp.put(att_name, i);
+    	}               
+    	return hp;
+    }
+    
+
+    public String[] getDocumentIDs(String core_element){
+	
+    	Element ex = getRootNode("archivedir");
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	String[] ids = new String[listOfFrequency.getLength()];
+    	
+	for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    Node docNode = listOfFrequency.item(s);
+	    NamedNodeMap NodeMap = docNode.getAttributes();
+	    Node AttributeNode = NodeMap.item(0);
+	    String att_name = AttributeNode.getNodeValue();
+	    ids[s] = att_name;
+    	}
+    	return (String[])ids.clone();
+    }
+    
+    public int[] getMetadataRows(String core_element){
+    	Element ex = getRootNode(core_element);
+    	//ArrayList alist = ms.getIDArray();
+    	ArrayList alist = new ArrayList();
+    	String[] idsx = getDocumentIDs(core_element);
+	
+    	for(int i = 0; i<idsx.length; i++){
+    		alist.add(idsx[i]);
+    	}
+
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	int[] row = new int[TotalDoc];
+	
+    	for(int i = 0; i<row.length; i++){
+    		row [i] = 0;
+    	}
+    	
+    	for(int s=0; s<listOfFrequency.getLength() ; s++){   
+    		Node docNode = listOfFrequency.item(s);
+    		int location = alist.indexOf(docNode.getAttributes().item(0).getNodeValue());
+    		row[location] =1;
+    
+   	}
+    	return row;
+    }
+        
+    /**
+     * This method will use Arrays.sort for sorting Map
+     * @param map
+     * @return outputList of Map.Entries
+     */
+
+    public ArrayList sortMap(Map map) {
+	ArrayList outputList = null;
+	int count = 0;
+	Set set = null;
+	Map.Entry[] entries = null;
+	//     Logic:
+	//     get a set from Map
+	//     Build a Map.Entry[] from set
+	//     Sort the list using Arrays.sort
+	//     Add the sorted Map.Entries into arrayList and return
+	
+	set = (Set) map.entrySet();
+	Iterator iterator = set.iterator();
+	entries = new Map.Entry[set.size()];
+	while(iterator.hasNext()) {
+	    entries[count++] = (Map.Entry) iterator.next();
+	}
+	
+	//     Sort the entries with your own comparator for the values:
+	Arrays.sort(entries, new Comparator() {
+		public int compareTo(Object lhs, Object rhs) {
+		    Map.Entry le = (Map.Entry)lhs;
+		    Map.Entry re = (Map.Entry)rhs;
+		    return ((Comparable)le.getValue()).compareTo((Comparable)re.getValue());
+		}
+		
+		public int compare(Object lhs, Object rhs) {
+		    Map.Entry le = (Map.Entry)lhs;
+		    Map.Entry re = (Map.Entry)rhs;
+		    return ((Comparable)le.getValue()).compareTo((Comparable)re.getValue());
+		}
+	    });
+
+	outputList = new ArrayList();
+	for(int i = 0; i < entries.length; i++) {
+	    outputList.add(entries[i]);
+	}
+	return outputList;
+    }//End of sortMap
+    
+    private Double div(Double d1, Double d2){
+    	BigDecimal b1 = new BigDecimal(d1.toString());
+        BigDecimal b2 = new BigDecimal(d2.toString());
+        return new Double(b1.divide(b2,DEF_DIV_SCALE,BigDecimal.ROUND_HALF_UP).doubleValue());
+    }
+    
+    private Double mul(Double d1,Double d2){
+        BigDecimal b1 = new BigDecimal(d1.toString());
+        BigDecimal b2 = new BigDecimal(d2.toString());
+        return new Double(b1.multiply(b2).doubleValue());
+    }
+    
+    public double round(double v,int scale){
+        if(scale<0){
+            throw new IllegalArgumentException(
+					       "The scale must be a positive integer or zero");
+        }
+        BigDecimal b = new BigDecimal(Double.toString(v));
+        BigDecimal one = new BigDecimal("1");
+        return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+    
+    public double getSingleMetadataSetCompleteness(ArrayList mds_list){
+   
+    	int totalElement = 0;
+    	int totalElementUsed = 0;
+    
+	for(int a = 0; a<mds_list.size(); a++){
+	    MetadataSet mds = (MetadataSet)mds_list.get(a);
+	
+	    ArrayList alist = mds.getIndexsList();
+
+	    int length = alist.size();
+
+	    totalElement = totalElement + length * TotalDoc;
+	    for(int i = 0; i<alist.size(); i++){
+	    	String name = (String)alist.get(i);
+	    	
+	    	totalElementUsed = totalElementUsed + getDocumentUsedElement(name);
+	  
+	    }
+	}
+    	double x = (double)totalElementUsed/totalElement;
+    	Double d1 = new Double(x);
+    	Double d2 = new Double(100);
+    	Double result = mul(d1,d2);
+    
+    	return round(result.doubleValue(),1);
+    }
+    
+    public Object[][] getMetadataInfo(MetadataSet mds){
+    	
+    	ArrayList alist = mds.getIndexsList();
+    	int rows = alist.size();
+    	int cols = 11;
+    	int y = 0;
+    	Object[][] dataset = new Object[rows][cols];
+    	
+       	String[] list = new String[rows];
+    	
+	for(int i = 0 ; i < list.length; i++){
+	    list[i] = alist.get(i).toString();
+	 
+    	}
+	
+    	Arrays.sort(list);
+    	
+    	for(int iu = 0; iu<list.length; iu++){
+    	    String xi = list[iu];
+    	    dataset[y][0] = xi ;
+    	    dataset[y][1] = new Integer(getFrequency(xi));
+    	    dataset[y][2] = new Integer(getDocumentUsedElement(xi));
+    	    dataset[y][3] = new Double (Mean(xi));
+    	    dataset[y][4] = new Double (Median(xi));
+    	    dataset[y][5] = new Integer(getDistinctNumber(xi));
+    	    dataset[y][6] = new Integer(getMinRange(xi));
+    	    dataset[y][7] = new Integer(getMaxRange(xi));
+    	    dataset[y][8] = new Double (Average(xi));
+    	    dataset[y][9] = new Integer(getMode(xi));
+    	    dataset[y][10] = ModeFrequency(xi)+"%";
+	    y++;
+	    
+    	}
+    	return dataset;
+    }
+    
+    public boolean IsElementEmpty(String core_element){
+    	
+    	int[] list = getMetadataRows(core_element);
+    	boolean status = true;
+    	
+	for(int i = 0; i< list.length; i++){
+    		if(list[i]==1){status = false;}
+    	}
+    	return status;
+    }
+    
+    public boolean IsElementFull(String core_element){
+    	
+    	int[] list = getMetadataRows(core_element);
+    	boolean status = true;
+    	
+	for(int i = 0; i< list.length; i++){
+    		if(list[i]==0){status = false;}
+    	}
+    	return status;
+    }
+    
+    public ArrayList removeDocument(ArrayList dataset, String[] ids, int number){
+    	removedID = new ArrayList();
+    	
+    	int[] metadataLevel =(int[])dataset.get(0);
+    	int docIDslength = metadataLevel.length;
+    	int[][] valueMap = new int[dataset.size()][docIDslength];
+    	
+    	for(int i = 0; i< docIDslength; i++){
+    		
+    		boolean status = true;
+    		
+    		for(int j = 0; j<dataset.size(); j++){
+    		 int[] metadataLevelArray = (int[])dataset.get(j);
+    		 valueMap[j][i] =  metadataLevelArray[i];
+    		 if(metadataLevelArray[i]!=number){status = false;}
+    	
+    		}
+    		if(status == true){
+		
+		    for(int j = 0; j<dataset.size(); j++){
+
+			valueMap[j][i]=-1;
+
+		    }
+		    removedID.add(ids[i]);
+    		}
+    	}
+    	ArrayList wholeList = new ArrayList();
+
+    	for(int i = 0; i<valueMap.length; i++){
+	    ArrayList numberList = new ArrayList();
+	    
+	    for(int j = 0; j<valueMap[i].length; j++){
+		numberList.add(new Integer(valueMap[i][j]));
+	    }
+	    wholeList.add(numberList);
+    	}
+    	
+    	for(int i =0; i< wholeList.size(); i++){
+	    ArrayList numberList = (ArrayList)wholeList.get(i);
+	    Integer value = new Integer(-1);
+	    while(numberList.contains(value)){
+		numberList.remove(value);
+	    }
+	    int[] valueList = new int [numberList.size()];
+	    
+	    for(int j = 0; j< valueList.length; j++){
+		valueList[j] = ((Integer)numberList.get(j)).intValue();
+	    }
+	    wholeList.remove(i);
+	    wholeList.add(i,valueList);
+    	}
+   
+    	return wholeList;
+    }
+    
+    public ArrayList getRemovedID(){
+    	return removedID;
+    }
+    
+    public int getDocNum(){
+    	return TotalDoc;
+    }
+       
+    public HashMap getInternalIdentifier(String core_element){
+    	
+    	Element ex = getRootNode(core_element);
+        HashMap hp = new HashMap();
+        NodeList listOfFrequency = ex.getElementsByTagName("Document");
+        	
+    	for(int s=0; s<listOfFrequency.getLength() ; s++){
+    	    Node docNode = listOfFrequency.item(s);
+    	    String HashID = docNode.getAttributes().item(0).getNodeValue();
+    	    //System.out.println(HashID);
+    	    Element docElement = (Element)docNode;
+    	    NodeList valueList = docElement.getElementsByTagName("ActualValue");
+    	    
+    	    for(int y = 0; y<valueList.getLength(); y++){
+    		Element valueElement = (Element)valueList.item(y);
+    		NodeList textFNList = valueElement.getChildNodes();
+    		String text = ((Node)textFNList.item(0)).getNodeValue();
+    		
+    		if(!text.equals(" ")){
+    		    if(hp.containsKey(text)){
+    			InternalLink il = (InternalLink)hp.get(text);
+    			il.increaseElement(HashID);
+    			hp.put(text,il);
+    		    }
+    		    else{
+    		    InternalLink il = new InternalLink();
+    			il.setValue(text);
+    			il.increaseElement(HashID);
+    			hp.put(text, il);
+    		    }
+    		}
+    	    }
+        	}               
+        	return hp;
+        }
+        
+
+    public HashMap getIdentifierLink(String core_element){
+    	
+    	Element ex = getRootNode(core_element);
+        HashMap hp = new HashMap();
+        NodeList listOfFrequency = ex.getElementsByTagName("Document");
+        	
+    	for(int s=0; s<listOfFrequency.getLength() ; s++){
+    	    Node docNode = listOfFrequency.item(s);
+    	    String HashID = docNode.getAttributes().item(0).getNodeValue();
+    	    Element docElement = (Element)docNode;
+    	    NodeList valueList = docElement.getElementsByTagName("ActualValue");
+    	    
+    	    for(int y = 0; y<valueList.getLength(); y++){
+    		Element valueElement = (Element)valueList.item(y);
+    		NodeList textFNList = valueElement.getChildNodes();
+    		String text = ((Node)textFNList.item(0)).getNodeValue();
+    		
+    		if(!text.equals(" ") && text.startsWith("http:")){
+    		    if(hp.containsKey(HashID)){
+    			InternalLink il = (InternalLink)hp.get(HashID);
+    			il.increaseElement(text);
+    			hp.put(HashID,il);
+    		    }
+    		    else{
+    		    InternalLink il = new InternalLink();
+    			il.setValue(HashID);
+    			il.increaseElement(text);
+    			hp.put(HashID, il);
+    		    }
+    		}
+    	    }
+        	}               
+        	return hp;
+        }
+
+    
+    public String[] getDocumentIDList(String core_element){
+    	
+    	Element ex = getRootNode(core_element);
+    	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+    	String[] ids = new String[listOfFrequency.getLength()];
+    	
+	for(int s=0; s<listOfFrequency.getLength() ; s++){
+	    Node docNode = listOfFrequency.item(s);
+	    NamedNodeMap NodeMap = docNode.getAttributes();
+	    Node AttributeNode = NodeMap.item(0);
+	    String att_name = AttributeNode.getNodeValue();
+	    ids[s] = att_name;
+    	}
+    	return (String[])ids.clone();
+    }
+
+}
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DescribeMessager.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DescribeMessager.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DescribeMessager.java	(revision 17184)
@@ -0,0 +1,344 @@
+package org.greenstone3.ms;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+
+import java.io.*;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.greenstone.gsdl3.core.MessageRouter;
+import org.greenstone.gsdl3.util.GlobalProperties;
+import org.greenstone.gsdl3.util.GSFile;
+import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.XMLConverter;
+import org.greenstone.gsdl3.util.GDBMWrapper;
+
+public class DescribeMessager {
+    
+    protected String site_name = "localsite";
+    
+    
+    /** message router object to pass requests messages to and which 
+     * will process them.*/
+    protected MessageRouter mr = null;
+    private Node CollectionList = null;
+    /** container Document to create XML Nodes */
+    protected Document doc=null;
+    /** a converter class to parse XML and create Docs */
+    protected XMLConverter converter=null;
+    
+    protected final static String mrSubsetOptions = //messageRouter 
+	"collectionList serviceClusterList serviceList siteList"; 
+    protected final static String csSubsetOptions = //collections and serviceClusters 
+	"metadataList serviceList displayItemList";
+    protected final static String serviceSubsetOptions = //services
+	"paramList displayItemList";
+    final int MESSAGEROUTER = 1, COLLECTION = 2, 
+	SERVICECLUSTER = 3, SERVICE = 4;
+    
+    private String collection_Name = null;
+    private String OAI_URL = null;
+    protected GDBMWrapper gdbm_src = null;
+    protected String site_name1 = "";
+    protected String coll_name1 = "";
+    protected Element coll_config_xml = null;
+    protected HashMap element_map = new HashMap();
+    protected MetadataStats ms;
+    String site_home = null;
+    
+    public DescribeMessager() {
+
+	String gsdl3_home = GlobalProperties.getGSDL3Home();
+	if (gsdl3_home == null || gsdl3_home.equals("")) {
+	    System.err.println("Couldn't access GSDL3Home from GlobalProperties.getGSDL3HOME, can't initialize the SOAP Server.");
+	    return;
+	}
+
+	
+	site_home = GSFile.siteHome(gsdl3_home, this.site_name);
+	
+	File site_file = new File(site_home);
+	if (!site_file.isDirectory()) {
+	    System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialize the SOAP Server.");
+	    return;
+	} 
+	this.converter = new XMLConverter();
+	this.doc = this.converter.newDOM();
+	System.err.println("3");
+	mr = new MessageRouter();
+
+	mr.setSiteName(this.site_name);
+	mr.setLibraryName(this.site_name);
+
+	mr.configure();
+	/*
+	try{
+	
+	mr.
+	}catch(Exception ex){ex.printStackTrace();}
+	*/
+	System.err.println("6");
+
+	this.gdbm_src = new GDBMWrapper();
+	System.err.println("7");
+
+	
+    }
+    
+    public DescribeMessager(String collectionName, String URL) {
+    	
+    	collection_Name = collectionName;
+    	OAI_URL = URL;
+    	
+    	String gsdl3_home = GlobalProperties.getGSDL3Home();
+    	if (gsdl3_home == null || gsdl3_home.equals("")) {
+    	    System.err.println("Couldn't access GSDL3Home from GlobalProperties.getGSDL3HOME, can't initialize the SOAP Server.");
+    	    return;
+    	}
+    	
+    	site_home = GSFile.siteHome(gsdl3_home, this.site_name);
+    	
+    	File site_file = new File(site_home);
+    	if (!site_file.isDirectory()) {
+    	    System.err.println("The site directory "+site_file.getPath()+" doesn't exist. Can't initialize the SOAP Server.");
+    	    return;
+    	} 
+    	this.converter = new XMLConverter();
+    	this.doc = this.converter.newDOM();
+    	
+    	mr = new MessageRouter();
+    	mr.setSiteName(this.site_name);
+    	//mr.configure();
+    	this.gdbm_src = new GDBMWrapper();
+    	//describe();
+    }
+    /*
+    public void setURL(String arg){
+    	OAI_URL = arg;
+    }
+    */
+    
+    public void setCollectionName(String arg){
+    	collection_Name = arg;
+    }
+    
+    public String describe() 
+    {
+	return describe("", "", "", mrSubsetOptions);
+    }
+    
+    /*
+    public String getURL(){
+    	return OAI_URL;
+    }
+    */
+    
+    public String getCollectionName(){
+    	return collection_Name;
+    }
+    
+    /*
+    //Describe Messages sent to Services (or Collection/Services) 
+    public String describeCollService(String toColl, String toService, 
+				      String lang, String subsetOption) {
+
+	return describe(toColl + "/" + toService, 
+			lang, subsetOption, serviceSubsetOptions);
+    }
+    */
+    //If public, this method would give full access: a describe message that 
+    //lets the user specify all the details of who the receiver is, and what 
+    //details are requested.
+    protected String describe(String to, String lang, 
+			      String subsetOption, String validSubsetOptions)
+    {
+    	
+	//Create message element: <message></message>
+	try{
+	    //DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+	    //Get the DocumentBuilder
+	    //DocumentBuilder parser = factory.newDocumentBuilder();
+	    //Create blank DOM Document
+	    //Document doct = parser.newDocument();
+	
+	    Node message = doc.createElement(GSXML.MESSAGE_ELEM);
+	    
+	    //<message><request lang="en" to="" type="describe" uid="" /></message>
+	    
+	    Node request = GSXML.createBasicRequest(
+						       this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, lang, "");
+	    
+	    //Check if only a subset of this Module Interface's data is asked
+	    //to be described
+	    
+	    if(subsetOption != "") {
+		//Now deal with the value for subset param:
+		//only deal with valid params for subset of to-ModuleInterface
+		if(validSubsetOptions.indexOf(subsetOption) == -1)
+		    return "Invalid List to be described. Choose one of:\n"
+			+ validSubsetOptions;
+		
+		//else, append <paramList />
+		Node param_list = this.doc.createElement(
+							    GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+		param_list.appendChild(GSXML.createParameter(
+							     this.doc, GSXML.SUBSET_PARAM, subsetOption));
+		request.appendChild(param_list);
+		
+	    }
+	    message.appendChild(request);
+	    //System.out.println(this.converter.getPrettyString(message));
+	    /*
+	    Element request = GSXML.createBasicRequest(
+			       this.doc, GSXML.REQUEST_TYPE_PROCESS,"nwgfril"+"/DocumentMetadataRetrieve","en", "");
+
+Element param_list = this.doc.createElement(
+				GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+
+param_list.appendChild(GSXML.createParameter(
+				 this.doc, "metadata", "all"));
+
+Element documentNode_list = this.doc.createElement(
+	       GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
+
+Element documentNode = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+documentNode.setAttribute("nodeID","HASH01981d6a4a1502253e1a2283");
+documentNode_list.appendChild(documentNode);
+
+request.appendChild(param_list);
+request.appendChild(documentNode_list);
+message.appendChild(request);
+System.out.println(this.converter.getPrettyString(message));
+*/
+	   // message.appendChild(request);
+	    //System.out.println("\nRequest message");
+	    //System.out.println(this.converter.getPrettyString(message));
+	    //System.out.println(this.converter.getPrettyString(message));
+	    //////////////////////////////////////////////////////////////////////////////////////////////
+	    ////////////////////////////////////////////////////////////////////////////////////////////////
+	    CollectionList = mr.process(message);
+	    //System.out.println(this.converter.getPrettyString(CollectionList));
+	    //Element response = mr.process(message);
+	    //System.out.println(this.converter.getPrettyString(response));
+	    //System.out.println("list"+CollectionList);
+	    return ">>"+GSXML.MESSAGE_ELEM+"<<";
+	    //return request.;
+	}catch(Exception ex){return "failure";}
+	//return this.converter.getPrettyString(message.toString());
+	//return this.converter.getPrettyString(CollectionList);
+
+    }
+    
+    public Node getCollectionList(){
+    	return CollectionList;
+    }
+
+
+    public void describeMatadata(String collectionName,String OAIURL){
+
+	ms = new MetadataStats(this.site_home,collectionName,OAIURL,"test");
+	
+	if(ms.getStatus()){
+		//return;
+		printWebPage(ms);
+	}
+	// Servlet-------------------------------------------------
+	else{
+		System.out.print("<p> The metadataStats fails</p>");
+	}
+	//System.out.println("\nTotal Number of Documents: "+ms.getDocNum());
+	//System.out.println("\n system ends");
+	//System.out.println(ms.metadataNameList.size());
+
+    }
+
+    public void printWebPage(MetadataStats ms){
+    	//long startTime=System.currentTimeMillis();	
+    	DataMaker dm = new DataMaker(ms);
+    	String[] elements =  new String [ms.metadataNameList.size()];
+        
+    	for(int i = 0; i<elements.length; i++){
+    		elements[i] = (String)ms.metadataNameList.get(i);
+        }
+	
+        Arrays.sort(elements);
+    	String[] metaDataElementName = (String[])elements.clone();	
+    	String[] ids = dm.getDocumentIDs("archivedir");
+        
+    	ArrayList alist = new ArrayList();
+    	for(int a = 0; a<elements.length; a++){
+    		alist.add(dm.getMetadataRows(elements[a]));
+    	}
+    	//System.out.println(alist.size()+ " " +ids.length+" "+metaDataElementName.length);   	
+    	PrintHTML phtml = new PrintHTML(ms);
+
+    	//?????????????????????????????????????????????????????????????????????????/
+    	HashMap hp = ms.getMetadataSetMap();
+    	Collection c = hp.values();
+    	Iterator i = c.iterator();
+    	
+    	while(i.hasNext()){
+    		MetadataSet mds  = (MetadataSet)i.next();
+    		//if(!mds.getName().equals("extracted")){
+    		ArrayList elementList = mds.getIndexsList();
+    		String[] mdsElement = new String[elementList.size()];
+    		for(int x = 0; x<mdsElement.length; x++){
+    			mdsElement[x]=(String)elementList.get(x);
+    		}
+    		Arrays.sort(mdsElement);
+    		
+        	String[] metaDataElement = (String[])mdsElement.clone();	
+        	String[] idList = dm.getDocumentIDs("archivedir");
+            
+        	ArrayList datalist = new ArrayList();
+        	for(int a = 0; a<mdsElement.length; a++){
+        		datalist.add(dm.getMetadataRows(mdsElement[a]));
+        	}
+        	phtml.generateAllPossibleGraph(datalist,idList,metaDataElement,mds.getName());
+    		//}
+    	}
+    	
+    	//??????????????????????????????????????????????????????????????????????????
+    	//long startTime=System.currentTimeMillis();
+    	//phtml.generateAllPossibleGraph(alist,ids,metaDataElementName,"both");
+    	//////////////////////////////////
+    	//Now generate chart  for individaul mds
+    	//????????????????????????????????????????????????????????//
+    	
+    	//long endTime=System.currentTimeMillis();
+    	//System.out.println("Total time taken for generating overall Statistics Page "+(endTime-startTime)+ " millisec");
+
+    	phtml.generateOverallStatisticsPage(hp);
+
+    	Collection cx = ms.getMetadataSetMap().values();
+    	Iterator ix = cx.iterator();
+
+    	while(ix.hasNext()){
+    		MetadataSet temp = (MetadataSet)ix.next();
+    		phtml.WriteMetadataSetDetailHTML(temp);
+    		phtml.generateMetadataElementDetailPage(temp);
+    	}
+    }
+ 
+    
+    public MetadataStats getElementClass()
+    {
+	return ms;
+    }
+    
+    public static void main(String[] args) {
+    	//DescribeMessager dm = new DescribeMessager();
+    	//System.out.println("test");
+    	//dm.describe("","","","");
+    	//dm.describeMatadata("sampleco","http://researchcommons.waikato.ac.nz/cgi/oai2.cgi");
+    }
+}
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DocumentInfo.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DocumentInfo.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DocumentInfo.java	(revision 17184)
@@ -0,0 +1,41 @@
+package org.greenstone3.ms;
+
+import java.util.ArrayList;
+
+public class DocumentInfo {
+    
+    private String DocumentID;
+    private ArrayList ActualValue;
+    private int Frequence;
+    
+    public DocumentInfo(){
+    	DocumentID = null;
+    	ActualValue = new ArrayList();
+    	Frequence = 0;
+    }
+    
+    public void IncreaseFrequence(){
+    	Frequence++;
+    }
+     
+    public void addActualValue(String v){
+    	ActualValue.add(v);
+    }
+    
+    public void setDocumentID(String ID){
+    	DocumentID = ID;
+    }
+    
+    public ArrayList getActualValue(){
+    	return ActualValue;
+    }
+
+    public int getFrequence(){
+    	return Frequence;
+    }
+    
+    public String getDocumentID(){
+    	return DocumentID;
+    }
+
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DrawSymbolAxis.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DrawSymbolAxis.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DrawSymbolAxis.java	(revision 17184)
@@ -0,0 +1,99 @@
+package org.greenstone3.ms;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.util.ArrayList;
+import javax.swing.JPanel;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.NumberTickUnit;
+import org.jfree.chart.axis.SymbolAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
+import org.jfree.data.xy.XYDataset;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+import org.jfree.ui.ApplicationFrame;
+import org.jfree.ui.RefineryUtilities;
+
+public class DrawSymbolAxis extends ApplicationFrame
+{
+	//private String Title;
+	private static String[] metadataName;
+
+	private static String[] documentIDs;
+
+	private static ArrayList dataset;
+	
+    public DrawSymbolAxis(String string, String[] metadata, String[] ids, ArrayList set) {
+        super(string);
+        //Title = string;
+        metadataName = metadata;
+        documentIDs = ids;
+        dataset = set;
+
+        JPanel jpanel = createDemoPanel();
+
+        setContentPane(jpanel);
+        
+        pack();
+        RefineryUtilities.centerFrameOnScreen(this);
+        setVisible(true);
+    }
+
+    private static JFreeChart createChart(XYDataset xydataset) {
+        SymbolAxis symbolaxis
+        = new SymbolAxis("Document ID", documentIDs);
+        SymbolAxis symbolaxis_0_
+        = new SymbolAxis("Indexes",  metadataName);
+
+        XYLineAndShapeRenderer xylineandshaperenderer
+        = new XYLineAndShapeRenderer(false, true);
+
+        XYPlot xyplot = new XYPlot(xydataset,symbolaxis_0_,symbolaxis,
+                                   xylineandshaperenderer);
+        xyplot.setDomainGridlinePaint(Color.black);
+        xyplot.setRangeGridlinePaint(Color.black);
+
+        NumberAxis domainAxis = (NumberAxis)xyplot.getDomainAxis(); 
+        domainAxis.setAutoTickUnitSelection(true);
+        double   rangetick = 1;
+        domainAxis.setTickUnit(new NumberTickUnit(rangetick));
+
+        xyplot.getRenderer().setSeriesPaint(0,Color.blue);
+        xyplot.getRenderer().setSeriesShape(0, xyplot.DEFAULT_LEGEND_ITEM_BOX);
+        JFreeChart jfreechart = new JFreeChart("",new Font("", Font.PLAIN, 12),xyplot,false);        
+        return jfreechart;
+    }
+
+    private static XYDataset createDataset() {
+
+    	XYSeries xyseries = new XYSeries("Series");
+
+        for(int a= 0; a<dataset.size(); a++){
+        	
+        	int[] row = (int[])dataset.get(a);
+        	//System.out.print
+        	for(int b = 0; b<row.length; b++){
+        		if(row[b]==1){xyseries.add(a,b);}
+        	}
+        	     
+        }
+
+        XYSeriesCollection xyseriescollection = new XYSeriesCollection();
+        xyseriescollection.addSeries(xyseries);
+        return xyseriescollection;
+    }
+
+    public static JPanel createDemoPanel() {
+        return new ChartPanel(createChart(createDataset()));
+    }
+    public static void main(String[] strings) {
+    	DrawSymbolAxis symbolaxisdemo1 = new DrawSymbolAxis("Symbolic Axis Demo", null, null, null);
+
+    }
+    public void windowClosing(java.awt.event.WindowEvent event){
+    	this.dispose();
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DrawXYChart.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DrawXYChart.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/DrawXYChart.java	(revision 17184)
@@ -0,0 +1,120 @@
+package org.greenstone3.ms;
+import java.awt.Dimension;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.JPanel;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.CategoryAxis;
+import org.jfree.chart.axis.CategoryLabelPositions;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.BarRenderer;
+import org.jfree.chart.renderer.category.CategoryItemRenderer;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.ApplicationFrame;
+import org.jfree.ui.RefineryUtilities;
+
+public class DrawXYChart extends ApplicationFrame
+{
+    //private static String Title = null;
+    private static String Item = null;
+    private static HashMap map = new HashMap();
+    
+    public DrawXYChart(String str1, String str2, HashMap hp, int operation) {
+        super("Frequency V.S "+str2);
+        //Title = str1;
+        Item = str2;
+        map = hp;
+        
+        JPanel jpanel = createDemoPanel(operation);
+        jpanel.setPreferredSize(new Dimension(500, 270));
+        setContentPane(jpanel);
+        
+        pack();
+        RefineryUtilities.centerFrameOnScreen(this);
+        setVisible(true);
+    }
+
+    private static CategoryDataset createDataset() {
+        DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
+        //MetadataElement me = (MetadataElement) map.get(Item);
+        //Set tempMap = map.keySet();
+        Set s = map.keySet();
+        Iterator i = s.iterator();
+        //int counter = 1;
+        
+	while(i.hasNext()){
+	    String metaName = (String)i.next();
+	    Integer in = (Integer)map.get(metaName);
+	    int number = in.intValue();
+	    defaultcategorydataset.addValue(number,metaName,metaName);
+	    //counter++;
+        }
+	
+        return defaultcategorydataset;
+    }
+    
+    private static CategoryDataset createDataset2() {
+        DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
+
+        Set s = map.keySet();
+        Iterator i = s.iterator();
+        int counter = 0;
+        
+	while(i.hasNext()){
+	    String metaName = (String)i.next();
+	    Integer in = (Integer)map.get(metaName);
+	    int number = in.intValue();
+	    defaultcategorydataset.addValue(number , metaName, counter+"");
+	    counter++;
+        }
+	
+        return defaultcategorydataset;
+    }
+    
+    private static JFreeChart createChart(CategoryDataset categorydataset) {
+        JFreeChart jfreechart
+	    = ChartFactory.createBarChart3D("",Item,
+					    "Frequency", categorydataset,
+					    PlotOrientation.VERTICAL, false,
+					    true, false);
+	
+        CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
+        CategoryAxis categoryaxis = categoryplot.getDomainAxis();
+        categoryaxis.setCategoryLabelPositions
+	    (CategoryLabelPositions
+	     .createUpRotationLabelPositions(0.39269908169872414));
+        CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
+        categoryitemrenderer.setBaseItemLabelsVisible(true);
+        BarRenderer barrenderer = (BarRenderer) categoryitemrenderer;
+        barrenderer.setItemMargin(0.2);
+        return jfreechart;
+    }
+
+    public static JPanel createDemoPanel(int operation) {
+        JFreeChart jfreechart = createChart(createDataset());
+        if(operation == 2){
+        	jfreechart = createChart(createDataset2());
+        }
+        return new ChartPanel(jfreechart);
+    }
+    
+    public static void main(String[] strings) {
+        DrawXYChart DrawXYChart
+	    = new DrawXYChart("3D Bar Chart Demo 3", "title2",null,2);
+        DrawXYChart.pack();
+        RefineryUtilities.centerFrameOnScreen(DrawXYChart);
+        DrawXYChart.setVisible(true);
+    }
+    
+    public void windowClosing(java.awt.event.WindowEvent event){
+    	this.dispose();
+    }
+}
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/Frame1.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/Frame1.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/Frame1.java	(revision 17184)
@@ -0,0 +1,56 @@
+package org.greenstone3.ms;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.util.ArrayList;
+
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2007</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class Frame1 extends JFrame {
+    JPanel contentPane;
+    BorderLayout borderLayout1 = new BorderLayout();
+    ArrayList metaList;
+    MetadataStats mdst;
+    //JPanel jPanel1 = new JPanel();
+    
+    public Frame1(MetadataStats ms) {
+    	 mdst = ms;
+    	 metaList = ms.metadataNameList;
+        try {
+            setDefaultCloseOperation(EXIT_ON_CLOSE);
+            jbInit();
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+    }
+    
+    /**
+     * Component initialization.
+     *
+     * @throws java.lang.Exception
+     */
+    private void jbInit() throws Exception {
+        contentPane = (JPanel) getContentPane();
+        contentPane.setLayout(borderLayout1);
+        setSize(new Dimension(570, 800));
+	
+        setTitle("Metadata Statistics");
+        contentPane.add(BorderLayout.CENTER, new SummaryPanel(mdst));
+    }
+}
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/InternalLink.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/InternalLink.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/InternalLink.java	(revision 17184)
@@ -0,0 +1,28 @@
+package org.greenstone3.ms;
+
+import java.util.ArrayList;
+
+public class InternalLink {
+	private ArrayList alist = new ArrayList();
+	private ArrayList nodeList = new ArrayList();
+	private String value = "";
+	
+	public void setValue(String arg){
+		value = arg;
+	}
+	public void increaseElement(String arg){
+		alist.add(arg);
+	}
+	public String getValue(){
+		return value;
+	}
+	public ArrayList retrieveList(){
+		return (ArrayList)alist.clone();
+	}
+	public ArrayList retrieveNodeList(){
+		return (ArrayList)nodeList.clone();
+	}
+	public void increaseNode(InternalLink il){
+		nodeList.add(il);
+	}
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MainApplication.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MainApplication.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MainApplication.java	(revision 17184)
@@ -0,0 +1,74 @@
+package org.greenstone3.ms;
+
+import java.awt.Toolkit;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import java.awt.Dimension;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2007</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class MainApplication {
+    boolean packFrame = false;
+
+    /**
+     * Construct and show the application.
+     */
+    public MainApplication(String collectionName) {
+    	DescribeMessager dm = new DescribeMessager(collectionName,"http://repositoryaut.lconz.ac.nz/cgi/oai2.cgi");
+    	dm.describeMatadata(collectionName,"http://researchcommons.waikato.ac.nz/cgi/oai2.cgi");
+    	//System.out.println("step1");
+    	//HashMap
+        Frame1 frame = new Frame1(dm.getElementClass());
+        // Validate frames that have preset sizes
+        // Pack frames that have useful preferred size info, e.g. from their layout
+        if (packFrame) {
+            frame.pack();
+        } else {
+            frame.validate();
+        }
+
+        // Center the window
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        Dimension frameSize = frame.getSize();
+        if (frameSize.height > screenSize.height) {
+            frameSize.height = screenSize.height;
+        }
+        if (frameSize.width > screenSize.width) {
+            frameSize.width = screenSize.width;
+        }
+        frame.setLocation((screenSize.width - frameSize.width) / 2,
+                          (screenSize.height - frameSize.height) / 2);
+        frame.setVisible(true);
+    }
+
+    /**
+     * Application entry point.
+     *
+     * @param args String[]
+     */
+    public static void main(String[] args) {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                try {
+                    UIManager.setLookAndFeel(UIManager.
+                                             getSystemLookAndFeelClassName());
+                } catch (Exception exception) {
+                    exception.printStackTrace();
+                }
+
+                new MainApplication("");
+            }
+        });
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataElement.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataElement.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataElement.java	(revision 17184)
@@ -0,0 +1,86 @@
+package org.greenstone3.ms;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+
+public class MetadataElement {
+    
+    protected String metadataName = null;;
+    protected int frequency = 0;
+    protected ArrayList length = new ArrayList();
+    protected HashMap metadataList= new HashMap();
+    protected boolean used = false;
+    protected HashMap valueList = new HashMap();
+    
+    public String getMetadataName(){
+	return this.metadataName;
+    }
+    
+    public HashMap getValueList(){
+	return valueList;
+    }
+    
+    public int getFrequency(){
+	return frequency;
+    }
+    
+    public ArrayList getLength(){
+	return length;
+    }
+    
+    public HashMap getMetadataList(){
+	return metadataList;
+    }
+        
+    public void setMetadataName(String Meta_Name){
+	metadataName =  Meta_Name;
+    }
+    
+    public void IncreaseFrequency(){
+	frequency++;
+    }
+    
+    public void DecreaseFrequency(){
+	frequency--;
+    }
+    
+    public void SetLengthList(int len){
+	Integer in = new Integer (len);
+	length.add(in);
+    }
+    
+    public void SetmetadataList(String ID, DocumentInfo doc){
+	//Integer in = new Integer (num);
+	//metadataList.add(in);
+	//metadataList = alist;
+	metadataList.put(ID, doc);
+    }
+    
+    public void SetStatus(boolean status){
+	used = status;
+    }
+    
+    public int[] sortArrayList(){
+	
+	int[] sortList = new int [metadataList.size()];
+	Collection c = metadataList.values();
+	Iterator i = c.iterator();
+	int x = 0;
+	
+	while(i.hasNext()){
+	    sortList[x] = ((DocumentInfo) i.next()).getFrequence();
+	    x++;
+	}
+	/*
+	  for(int i = 0; i < metadataList.size(); i++){
+	  sortList[i] = ((Integer)metadataList.get(i)).intValue();
+	  }
+	*/
+	Arrays.sort(sortList);
+	return sortList;
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataSet.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataSet.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataSet.java	(revision 17184)
@@ -0,0 +1,44 @@
+package org.greenstone3.ms;
+
+import java.util.ArrayList;
+
+public class MetadataSet {
+
+	private String Name;
+	private ArrayList indexs = new ArrayList();
+	private String abb;
+	
+	public void setName(String str){
+		Name = str;
+	}
+	
+	public void addIndex(String str){
+		if(!indexs.contains(str)){
+			indexs.add(str);
+		}
+	}
+	
+	public void setAbb(String str){
+		abb = str;
+	}
+	
+	public String getName(){
+		return Name;
+	}
+	
+	public ArrayList getIndexsList(){
+		return (ArrayList)indexs.clone();
+	}
+	
+	public String getAbb(){
+		return abb;
+	}
+	
+	public boolean IsContain(String str){
+		return indexs.contains(str);
+	}
+	
+	public void setIndexList(ArrayList alist){
+		indexs = (ArrayList)alist.clone();
+	}
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataStats.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataStats.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataStats.java	(revision 17184)
@@ -0,0 +1,668 @@
+package org.greenstone3.ms;
+
+
+import org.w3c.dom.*;
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.*;
+
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.greenstone.gsdl3.core.MessageRouter;
+import org.greenstone.gsdl3.util.DBInfo;
+import org.greenstone.gsdl3.util.GDBMWrapper;
+import org.greenstone.gsdl3.util.GSFile;
+import org.greenstone.gsdl3.util.GSXML;
+import org.greenstone.gsdl3.util.XMLConverter;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class MetadataStats {
+    
+    private Document doc=null;
+    private MessageRouter mr = null;
+    private XMLConverter converter=null;
+    private GDBMWrapper gdbm_src = null;
+    private String site_name = "localsite";
+    private String node_id = "browselist";
+    private String DLS_SET = "dls";
+    private String DC_SET = "dublin";
+    private String OAI_URL = "";
+    private boolean status = false;
+    private String oai_Prefix ="";
+    //private PrintWriter pw;
+    // servlet
+    final String destination = "/home/cc108/MRWks1/Greenstone3Project/";
+    private int TotalDoc = 0;
+    //private int TotalElement = 0;
+
+    private HashMap MDS_list = new HashMap();
+    
+    private String collection = null;
+    public ArrayList metadataNameList = new ArrayList();
+    public String myNewDir;
+    private String collection_Name = null;
+
+    
+    MetadataElement me;
+    /*
+      The constructor connects to the database and retrieve 
+      information for the collection
+    */
+    
+    private static boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            for (int i=0; i<children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+    
+        return dir.delete();
+    } 
+
+    public MetadataStats(String site_home, String collection,String url,String oaiPrefix){
+    	OAI_URL = url;
+    	collection_Name = collection; 
+    	oai_Prefix = oaiPrefix;
+    	//pw = out;
+    	
+	//myNewDir = collection+"/metadataStats";
+    	myNewDir =destination+collection+"/metadataStats";
+    	
+    	if(new File(myNewDir).exists()){deleteDir(new File(myNewDir));}
+    	new File(myNewDir).mkdirs();
+	    
+
+    	String gdbm = GSFile.collectionDatabaseFile(site_home,collection,collection,"gdbm");
+
+	mr = new MessageRouter();
+	mr.setSiteName(this.site_name);
+	mr.configure();
+	
+	this.collection = collection;
+	this.gdbm_src = new GDBMWrapper();
+	this.converter = new XMLConverter();
+	this.doc = this.converter.newDOM();
+	Setup(gdbm);
+    }
+    
+    public void getAvailableMetadataSets(String SetName,HashMap UsedMap, String SetAbbr){
+	
+	File metadata_directory = new File("/research/cc108/greenstone3/gli/metadata");
+	//File metadata_directory = new File("/greenstone3/gli/metadata");
+	//File metadata_directory = new File("C://Program Files//Greenstone3//gli//metadata");
+	
+	if (metadata_directory.exists()) {
+	    // Load just those .mds files in this directory, and return them
+	    File[] directory_files = metadata_directory.listFiles();
+
+	    for (int i = 0; i < directory_files.length; i++) {
+		File child_file = directory_files[i];
+		
+		if (!child_file.isDirectory() && child_file.getName().endsWith("mds")) {
+                    String fileName = child_file.getName();
+		    
+		    /////////////////////////
+		    //LOADING DLS CORE
+		    //---if(fileName.equals(SetName)&& fileName.equals("dls.mds") && DLS_STATUS){
+		    if(!MDS_list.containsKey(SetName)&& fileName.equals(SetName+".mds")){
+            		    
+			MetadataSet ms = new MetadataSet();
+			ms.setName(SetName);
+			ms.setAbb(SetAbbr);
+			
+			converter.newDOM();
+			Document d = converter.getDOM(child_file);
+			     
+			NodeList e = d.getElementsByTagName("Element");
+			     
+			int length = e.getLength();
+			
+			for(int y = 0; y<length; y++){
+			    Node temp = e.item(y);
+			    NamedNodeMap mmp = temp.getAttributes();
+			    
+			    if(!mmp.item(0).getNodeValue().equals("dc.Description")){
+			    	MetadataElement me = new MetadataElement();
+			    	//me.setMetadataName((SetAbbr+"."+mmp.item(0).getNodeValue().toLowerCase()));
+			    	me.setMetadataName((SetAbbr+"."+mmp.item(0).getNodeValue()));
+			    	//System.out.println(me.getMetadataName());
+			    	//.child_file............child_file
+			    	if(!metadataNameList.contains(me.getMetadataName())){
+			    		metadataNameList.add(me.getMetadataName());
+			    		ms.addIndex(me.getMetadataName());
+			    	}
+			    UsedMap.put(me.getMetadataName(),me);
+			    }
+			}
+
+			MDS_list.put(ms.getName(), ms);
+
+		    }// DLS FINISH
+		}
+    	    }
+	}   	
+    }
+    
+    // doc_list is the list of document ids
+    //MetadataElement represents which metadata element we want to explore
+    private void parseMetadata(ArrayList doc_list, String MetadataElement){
+    	//MetadataElement = "dc.contributor";
+	//System.out.println("parse metadata starts");
+	int counter = 0;
+	//int x = 0;
+	int docSize = doc_list.size();
+    	
+	System.out.print("<!-- prepare request -->");
+	while(true){
+    		
+	    Node message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+	
+	    Node request = GSXML.createBasicRequest(
+						       this.doc, GSXML.REQUEST_TYPE_PROCESS,collection+"/DocumentMetadataRetrieve","en", "");
+	    
+	    Node param_list = this.doc.createElement(
+							GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
+	    
+	    param_list.appendChild(GSXML.createParameter(
+							 this.doc, "metadata", "all"));
+	//metadatalist-dc
+	    Node documentNode_list = this.doc.createElement(
+							       GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
+	
+	    if(docSize>=300){
+		docSize = docSize - 300;
+		for(int i = 0; i<300; i++){
+		    Element documentNode = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+		    documentNode.setAttribute("nodeID",(String)doc_list.get(counter));
+		    documentNode_list.appendChild(documentNode);
+		    counter++;
+		}
+		request.appendChild(param_list);
+		request.appendChild(documentNode_list);
+		message.appendChild(request);
+		Node response = mr.process(message);
+		getAttributes(response);
+		
+		response  = null;
+		request = null;
+		param_list = null;
+		documentNode_list = null;
+		//System.gc();	
+		}
+	
+	    else if(docSize<300){
+		for(int i = 0; i<docSize; i++){
+		    Element documentNode = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+		    documentNode.setAttribute("nodeID",(String)doc_list.get(counter));
+		    documentNode_list.appendChild(documentNode);
+		    counter++;
+		}
+		request.appendChild(param_list);
+		request.appendChild(documentNode_list);
+		message.appendChild(request);
+
+		Node response = mr.process(message);
+		getAttributes(response);
+		response  = null;
+		request = null;
+		param_list = null;
+		documentNode_list = null;
+
+		break;
+	    }
+	}
+    }
+    
+    public boolean getStatus(){
+    	return this.status;
+    }
+    
+
+    private void Setup(String gdbm){
+
+	
+	if (!this.gdbm_src.openDatabase(gdbm,GDBMWrapper.READ)) {
+	    System.out.println("Could not open GDBM database!");
+	    
+	}
+	
+	else{
+		
+		  String info = this.gdbm_src.getValue("browselist");
+			
+		    if (info == null) {
+		    	System.out.println("cannot locate the list");
+		    }
+		    else{
+			
+			if (info == null) {
+				System.out.println("the db does not contain any info");
+			}
+			
+			ArrayList children = new ArrayList();
+			StringTokenizer st = new StringTokenizer(info, ";");
+			
+			while (st.hasMoreTokens()) {
+				String part = st.nextToken(";");
+		
+				
+				
+				if(part.contains("<contains>")){
+					part = part.replace("<contains>", "");
+				}
+				else if(part.contains("<thistype>")){
+
+					int location = part.indexOf("<thistype>");
+					part = part.substring(0,location-1);
+				}
+				children.add(part);
+				System.out.println("..."+part+".....2");
+
+			}
+			
+			gdbm_src.closeDatabase();
+			parseMetadata(children,"all");
+			TotalDoc = children.size();
+			System.out.println("Total Doc22222:"+TotalDoc);
+			status = true;
+	}
+	}
+    }
+
+    
+    public void getAttributes(Node f){
+	
+	HashMap UsedMap = new HashMap();
+    Element e = (Element) f;
+	NodeList metadataNode =  e.getElementsByTagName("metadata");
+	int length = metadataNode.getLength();
+	
+	for (int j = 0; j < length; j++){
+	    Node aNode = metadataNode.item(j);
+	    NamedNodeMap NodeMap = aNode.getAttributes();
+	    Node AttributeNode = NodeMap.item(0);
+	    String att_name = AttributeNode.getNodeValue();
+	    
+	    if(att_name.indexOf("dls.")!=-1){getAvailableMetadataSets(DLS_SET,UsedMap,"dls");}
+	    else if(att_name.indexOf("dc.")!=-1){getAvailableMetadataSets(DC_SET,UsedMap,"dc");}
+	    
+	}
+
+	adjust(UsedMap,e);
+	UsedMap = null;
+	e = null;
+	System.gc();
+    }
+    
+
+    /* 
+     * MATCH UP THE ELEMENTS FROM BOTH DOCUMENTS AND PRE-DEFINED METADATA SET
+     * MOVE THE ELEMENT FROM NOUSEDMAP TO USEDMAP IF THE ELEMENT HAS NOT BEEN DISCOVERED BEFORE
+     * INCREASE THE COUNTER ONCE THE ELEMENT IS RECONGNIZED
+     * CALCULATE THE TIMES OF ELEMENTS USED AND STORE IT INTO THE LIST
+     */
+    
+    private void adjust(HashMap UsedMap, Element response){
+
+
+	String DocID;;
+	NodeList nList = response.getElementsByTagName("documentNode");
+	int length = nList.getLength();
+	for (int j = 0; j <length;  j++){
+	    
+	    Node aNode = nList.item(j);
+	    NamedNodeMap NodeMap = aNode.getAttributes();
+	    Node AttributeNode = NodeMap.item(0);
+	    String att_name = AttributeNode.getNodeValue();
+	    DocID = att_name;
+
+	    NodeList childList = aNode.getChildNodes();
+	    Node nNode = childList.item(0);
+	    NodeList grandChildList = nNode.getChildNodes();
+	    
+	    int length1 = grandChildList.getLength();
+	    
+	    for(int e = 0; e<length1 ; e++){
+
+		Node xNode = grandChildList.item(e);
+		NamedNodeMap xNodeMap = xNode.getAttributes();
+		Node xAttributeNode = xNodeMap.item(0);
+		String xatt_name = xAttributeNode.getNodeValue();
+
+		NodeList cList = xNode.getChildNodes();
+		
+		String ActValue = cList.item(0).getNodeValue();
+
+
+		char firstchart = xatt_name.charAt(0);
+
+		
+		if(xatt_name.indexOf('^')!=-1){
+			xatt_name = xatt_name.replace('^', '.');
+		}
+		
+		if(UsedMap.containsKey(xatt_name)){
+
+		    MetadataElement met = (MetadataElement) UsedMap.get(xatt_name);
+		    met.IncreaseFrequency();
+		    HashMap metadataMap = met.getMetadataList();
+		    
+		    if(metadataMap.containsKey(DocID)){
+		
+			DocumentInfo dc = (DocumentInfo)metadataMap.get(DocID);
+			dc.IncreaseFrequence();
+			dc.addActualValue(ActValue);
+			metadataMap.put(DocID, dc);
+		    }
+		    else{
+	
+			DocumentInfo dc = new DocumentInfo();
+			dc.IncreaseFrequence();
+			dc.setDocumentID(DocID);
+			dc.addActualValue(ActValue);
+			metadataMap.put(DocID, dc);
+		    }
+		    
+		    HashMap valueMap = met.getValueList();
+		    if(valueMap.containsKey(ActValue)){
+			Integer f = (Integer)valueMap.get(ActValue);
+			int fx = f.intValue();
+			fx++;
+			valueMap.put(ActValue,new Integer(fx));
+		    }
+		    else{
+			valueMap.put(ActValue, new Integer(1));
+		    }
+		    
+		}
+		//else if ((!UsedMap.containsKey(xatt_name)) && (xatt_name.indexOf(".")==-1) && (!xatt_name.equals("prettymd")) && (!xatt_name.equals("Description")) && (Character.isLetter(firstchart)) && (xatt_name.indexOf("-")==-1)){
+		else if( (!UsedMap.containsKey(xatt_name)) && xatt_name.equals("archivedir")){   
+		    //pw.write("NEW EX element");
+		    String SetAbbr = "ex";
+		    String SetName = "extracted";
+		    
+		    MetadataSet ms = new MetadataSet();
+		    ms.setName(SetName);
+		    ms.setAbb(SetAbbr);
+		    
+		    MetadataElement me = new MetadataElement();
+		    me.setMetadataName(xatt_name);
+		    me.IncreaseFrequency();
+		    HashMap metadataMap = me.getMetadataList();
+	    	
+		    if(metadataMap.containsKey(DocID)){
+			DocumentInfo dc = (DocumentInfo)metadataMap.get(DocID);
+			dc.IncreaseFrequence();
+			dc.addActualValue(ActValue);
+			metadataMap.put(DocID, dc);
+		    }
+		    else{
+			DocumentInfo dc = new DocumentInfo();
+			dc.IncreaseFrequence();
+			dc.setDocumentID(DocID);
+			dc.addActualValue(ActValue);
+			metadataMap.put(DocID, dc);
+		    }
+
+		    HashMap valueMap = me.getValueList();
+		    if(valueMap.containsKey(ActValue)){
+			Integer f = (Integer)valueMap.get(ActValue);
+			int fx = f.intValue();
+			fx++;
+			valueMap.put(ActValue,new Integer(fx));
+		    }
+		    else{
+
+			valueMap.put(ActValue, new Integer(1));
+		    }
+		    if(!metadataNameList.contains(me.getMetadataName())){
+		    	metadataNameList.add(me.getMetadataName());
+		    	ms.addIndex(me.getMetadataName());
+		    }
+
+		    UsedMap.put(me.getMetadataName(), me);
+		    if(!MDS_list.containsKey(ms.getName())){MDS_list.put(ms.getName(), ms);}
+		    else{
+			MetadataSet msx = (MetadataSet)MDS_list.get(ms.getName());
+			msx.addIndex(me.getMetadataName());
+			MDS_list.put(ms.getName(), msx);
+		    }
+		}
+		
+		
+		else if((!UsedMap.containsKey(xatt_name)) && xatt_name.indexOf(".")!=-1 && xatt_name.indexOf("dc.")==-1){   
+		    //pw.write("NEW EX element");
+			int dotLocation = xatt_name.indexOf(".");
+		    String SetAbbr = xatt_name.substring(0,dotLocation);
+		    String SetName = SetAbbr;
+		    
+		    MetadataSet ms = new MetadataSet();
+		    ms.setName(SetName);
+		    ms.setAbb(SetAbbr);
+		    
+		    MetadataElement me = new MetadataElement();
+		    me.setMetadataName(xatt_name);
+		    me.IncreaseFrequency();
+		    HashMap metadataMap = me.getMetadataList();
+	    	
+		    if(metadataMap.containsKey(DocID)){
+			DocumentInfo dc = (DocumentInfo)metadataMap.get(DocID);
+			dc.IncreaseFrequence();
+			dc.addActualValue(ActValue);
+			metadataMap.put(DocID, dc);
+		    }
+		    else{
+			DocumentInfo dc = new DocumentInfo();
+			dc.IncreaseFrequence();
+			dc.setDocumentID(DocID);
+			dc.addActualValue(ActValue);
+			metadataMap.put(DocID, dc);
+		    }
+
+		    HashMap valueMap = me.getValueList();
+		    if(valueMap.containsKey(ActValue)){
+			Integer f = (Integer)valueMap.get(ActValue);
+			int fx = f.intValue();
+			fx++;
+			valueMap.put(ActValue,new Integer(fx));
+		    }
+		    else{
+
+			valueMap.put(ActValue, new Integer(1));
+		    }
+		    if(!metadataNameList.contains(me.getMetadataName())){
+		    	metadataNameList.add(me.getMetadataName());
+		    	ms.addIndex(me.getMetadataName());
+		    }
+		    //pw.write("adding element");
+		    UsedMap.put(me.getMetadataName(), me);
+		    if(!MDS_list.containsKey(ms.getName())){MDS_list.put(ms.getName(), ms);}
+		    else{
+			MetadataSet msx = (MetadataSet)MDS_list.get(ms.getName());
+			msx.addIndex(me.getMetadataName());
+			MDS_list.put(ms.getName(), msx);
+		    }
+		}
+		
+		////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+		else if ((!UsedMap.containsKey(xatt_name)) && (xatt_name.indexOf("dc.")==0) && xatt_name.indexOf("dc.Description")!=0){
+		    
+		    //pw.write("QUALIFIED DC element");
+			
+		    String SetName = "dublin";
+		    xatt_name = xatt_name.replace('^', '.');
+		    
+		    MetadataElement me = new MetadataElement();
+		    me.setMetadataName(xatt_name);
+		    me.IncreaseFrequency();
+		    HashMap metadataMap = me.getMetadataList();
+		    
+		    DocumentInfo dc = new DocumentInfo();
+		    dc.IncreaseFrequence();
+		    dc.setDocumentID(DocID);
+		    dc.addActualValue(ActValue);
+		    metadataMap.put(DocID, dc);
+		    
+		    HashMap valueMap = me.getValueList();
+		    valueMap.put(ActValue, new Integer(1));
+			
+		    if(!metadataNameList.contains(me.getMetadataName())){
+		    	metadataNameList.add(me.getMetadataName());
+		    }
+		    
+		    //pw.write("adding element");
+		    UsedMap.put(me.getMetadataName(), me);
+		    
+		    MetadataSet msx = (MetadataSet)MDS_list.get(SetName);
+		    msx.addIndex(me.getMetadataName());
+		    MDS_list.put(SetName, msx);
+		}
+		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+	    }// element
+	    
+	}//doc id
+	////////////////////
+	//write file
+	int counter = 0;
+
+	
+	Set s = UsedMap.keySet();
+	Iterator is = s.iterator();
+
+	while(is.hasNext()){
+
+	    String fileName = (String)is.next();
+	    MetadataElement me = (MetadataElement)UsedMap.get(fileName);
+	    HashMap hp = me.getMetadataList();
+	    Collection ks = hp.values();
+	    Iterator iks = ks.iterator();
+		
+	    try{
+		
+		DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+		DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+		Document doc = docBuilder.newDocument();
+		Element root = doc.createElement("root");
+		boolean fileExist = (new File(myNewDir+"/"+fileName+".xml")).exists();
+		
+		if(!fileExist){
+		    root = doc.createElement("root");
+		}
+		else{
+		    doc = docBuilder.parse (new File(myNewDir+"/"+fileName+".xml"));
+		    root = doc.getDocumentElement();
+		}
+		
+		while(iks.hasNext()){
+		    
+		    DocumentInfo dc = (DocumentInfo)iks.next();
+		    Element docID = doc.createElement("Document");
+		    docID.setAttribute("id", dc.getDocumentID());
+		    //pw.write("doc id"+dc.getDocumentID());
+            	
+		    Element freq = doc.createElement("Frequency");
+		    Text text = doc.createTextNode(dc.getFrequence()+"");
+		    freq.appendChild(text);
+		    docID.appendChild(freq);
+            	
+		    Element actValue = doc.createElement("ActualValue");
+		    ArrayList alist = dc.getActualValue();
+		    if(alist.size()==0){
+            		text = doc.createTextNode(" ");
+            		actValue = doc.createElement("ActualValue");
+            		actValue.appendChild(text);
+            		docID.appendChild(actValue);
+            		}
+            
+		    for(int i = 0; i<alist.size(); i++){
+            		actValue = doc.createElement("ActualValue");
+            		String utf8String = new String(((String)alist.get(i)).getBytes(),"UTF-8");
+            		Text text1 = doc.createTextNode(utf8String);
+            		actValue.appendChild(text1);
+            		docID.appendChild(actValue);
+		    }	
+            	
+		    root.appendChild(docID);
+		    docID = null;
+		    counter++;
+            }
+ 
+		TransformerFactory   tf=TransformerFactory.newInstance();     
+		Transformer   transformer=tf.newTransformer();     
+		DOMSource   source=new   DOMSource(root);     
+		transformer.setOutputProperty(OutputKeys.INDENT,"yes");     
+		
+		Writer pwx= new  BufferedWriter(new OutputStreamWriter(new FileOutputStream(myNewDir+"/"+fileName+".xml"),"UTF-8"));     
+		StreamResult   result= new   StreamResult(pwx);     
+		transformer.transform(source,result);  
+		pwx.close();
+  			
+		root = null;
+		docBuilderFactory = null;
+		docBuilder = null;
+		doc = null;
+		
+	    }catch (Exception e) {
+		System.out.println(e);
+		//e.printStackTrace(pw);
+	    }
+	}
+    }
+    
+    public int getDocNum(){
+	return TotalDoc;
+    }
+        
+    public HashMap getMetadataSetMap(){
+    	MDS_list.remove("extracted");
+    	return (HashMap)MDS_list.clone();
+    }
+    
+    public String getCollectionName(){
+    	return collection_Name;
+    }
+    
+    public void setOAIURL(String url){
+    	OAI_URL = url;
+    }
+    
+    public String getOAIURL(){
+    	return OAI_URL;
+    }
+    
+    public String getOaiPrefix(){
+    	return oai_Prefix;
+    }
+    
+    public ArrayList getMetadataNameList(){
+    	return (ArrayList)metadataNameList.clone();
+    }
+    private String constructUpdateMessgae (){
+    	String message = "<message><request type='system' to=''><system type='configure' subset=''/></request></message>";
+    	return message;
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataTableFrame.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataTableFrame.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/MetadataTableFrame.java	(revision 17184)
@@ -0,0 +1,98 @@
+package org.greenstone3.ms;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableModel;
+//import javax.swing.table.TableRowSorter;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2007</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class MetadataTableFrame extends JFrame {
+    JPanel contentPane;
+    BorderLayout borderLayout1 = new BorderLayout();
+    JPanel jPanel1 = new JPanel();
+    JScrollPane jScrollPane1 = new JScrollPane();
+    JTable jTable1;
+
+    String[] columnNames;
+
+
+      Object[][] data;
+ 
+ 
+    public MetadataTableFrame(String[] dataNames, Object[][] dataset) {
+        try {
+            columnNames = dataNames;
+            data = dataset;
+            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+            jbInit();
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+    }
+
+    /**
+     * Component initialization.
+     *
+     * @throws java.lang.Exception
+     */
+    private void jbInit() throws Exception {   
+        contentPane = (JPanel) getContentPane();
+        contentPane.setLayout(borderLayout1);
+        //setSize(new Dimension(700,720));
+        setTitle("Statistics table");
+        
+        TableModel model = new DefaultTableModel(data,columnNames) {
+            public Class getColumnClass(int column) {
+              return getValueAt(0, column).getClass();
+            }
+          };
+        jTable1 = new JTable(model);
+        TableColumn column = null;
+        //TableRow 
+        
+        for (int i = 0; i < jTable1.getColumnCount(); i++) {
+            column = jTable1.getColumnModel().getColumn(i);
+            
+            if(i == 1 || i ==2 || i==10){
+                column.setPreferredWidth(100);
+            }
+            else{
+            	  column.setPreferredWidth(25);
+            }
+            //column.set
+        }
+     
+        jTable1.setEnabled(false);
+        jTable1.setSize(new Dimension(1200,700));
+        jScrollPane1 = new JScrollPane(jTable1);
+      
+        jScrollPane1.setPreferredSize(new Dimension(1200,700));
+
+        jPanel1.add(jScrollPane1);
+        jPanel1.setPreferredSize(jTable1.getSize());
+        contentPane.setPreferredSize(new Dimension(680,700));
+        contentPane.add(jPanel1, java.awt.BorderLayout.CENTER);
+        setSize(new Dimension(1250,700));
+    }
+    
+    public void windowClosing(java.awt.event.WindowEvent event){
+    	this.dispose();
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/PrintHTML.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/PrintHTML.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/PrintHTML.java	(revision 17184)
@@ -0,0 +1,3030 @@
+package org.greenstone3.ms;
+
+//import InternalLink;
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.*;
+
+public class PrintHTML {
+    
+	final String NORMAL = "normal";
+	final String WORST = "worst";
+	final String BEST = "best";
+	final String title1 ="Hide Empty Metadata ,";
+	final String title2 ="Hide Completed Metadata ,";
+	final String title3 ="Hide Documents with Empty Metadata ,";
+	final String title4 ="Hide Documents with Completed Metadata  ,";
+	final String title5 ="No Available Graph";
+	final String metadataSet1 = "Dublin Core";
+	final String metadataSet2 = "Extracted";
+	final String incompletedList="IncompletedList";
+	final String spaceLeft = "<I>&laquo;";
+	final String spaceRight = "&raquo;</I>";
+	final String space ="space";
+	final String oddChar ="odd Character";
+	HashMap url;
+	//servlet
+	//final String destination = "/research/cc108/greenstone3/web/mat/";
+    MetadataStats mds;
+    DataMaker dm;
+    Calendar cl;
+    SimpleDateFormat sdf;
+    public PrintHTML(MetadataStats ms){
+	mds = ms;
+	
+	dm = new DataMaker(mds);
+	cl=Calendar.getInstance(); 
+	
+	sdf = new SimpleDateFormat(" dd MMM yyyy 'at' HH:mm:ss z 'GMT'Z");
+	setupMetadataLink("metadataElementURL");
+    }
+	
+    private ArrayList getHideEmptyMetadataDetail(ArrayList dataset, String[] id, String[] metadataName){
+    	
+    if(id.length==0 || metadataName.length==0){return new ArrayList();}	
+	ArrayList detailList = new ArrayList();
+	ArrayList alist = new ArrayList();
+	ArrayList nameList = new ArrayList();
+	
+	for(int i = 0; i< metadataName.length; i++){
+	    if(!dm.IsElementEmpty(metadataName[i])){
+		alist.add(dm.getMetadataRows(metadataName[i]));
+		nameList.add(metadataName[i]);
+	    }
+	}
+	
+	String[] metaDataElementName = new String[nameList.size()];
+	
+	for(int i = 0; i< nameList.size(); i++){
+	    metaDataElementName[i] = nameList.get(i).toString();
+	}
+	
+	if(id.length==0 || metaDataElementName.length==0){return new ArrayList();}
+	
+	detailList.add(alist);
+	detailList.add(id);
+	detailList.add(metaDataElementName);
+
+	return detailList;
+    }
+	
+    private ArrayList getHideFullMetadataDetail(ArrayList dataset, String[] id, String[] metadataName){
+    	
+    if(id.length==0 || metadataName.length==0){return new ArrayList();}	
+	ArrayList detailList = new ArrayList();
+	ArrayList alist = new ArrayList();
+	ArrayList nameList = new ArrayList();
+	
+	for(int i = 0; i< metadataName.length; i++){
+	    if(!dm.IsElementFull(metadataName[i])){
+		alist.add(dm.getMetadataRows(metadataName[i]));
+		nameList.add(metadataName[i]);
+	    }
+	}
+	
+	String[] metaDataElementName = new String[nameList.size()];
+	
+	for(int i = 0; i< nameList.size(); i++){
+	    metaDataElementName[i] = nameList.get(i).toString();
+	}
+	
+	if(id.length==0 || metaDataElementName.length==0){return new ArrayList();}
+	
+	detailList.add(alist);
+	detailList.add(id);
+	detailList.add(metaDataElementName);
+	
+	return detailList;
+    }
+	
+    private ArrayList getHideEmptyDocumentDetail(ArrayList dataset, String[] id, String[] metadataName){
+    
+    if(id.length==0 || metadataName.length==0){return new ArrayList();}
+	ArrayList detailList = new ArrayList();
+	ArrayList alist = dm.removeDocument(dataset, id, 0);
+	ArrayList idList = dm.getRemovedID();
+	ArrayList newIDList = new ArrayList();
+	
+	for(int i = 0; i< id.length; i++){
+	    if(!idList.contains(id[i])){
+		newIDList.add(id[i]);
+	    }
+	}
+	id = new String[newIDList.size()];
+	for(int i = 0; i<newIDList.size(); i++){
+	    id[i] = newIDList.get(i).toString();
+	}
+	
+	if(id.length==0 || metadataName.length==0){return new ArrayList();}
+	
+	detailList.add(alist);
+	detailList.add(id);
+	detailList.add(metadataName);
+	
+	return detailList;
+    }
+    
+    private ArrayList getHideFullDocumentDetail(ArrayList dataset, String[] id, String[] metadataName){
+    
+    if(id.length==0 || metadataName.length==0){return new ArrayList();}
+	ArrayList detailList = new ArrayList();
+	ArrayList alist = dm.removeDocument(dataset, id ,1);
+	ArrayList idList = dm.getRemovedID();
+	ArrayList newIDList = new ArrayList();
+	
+	for(int i = 0; i< id.length; i++){
+	    if(!idList.contains(id[i])){
+		newIDList.add(id[i]);
+	    }
+	}
+	id = new String[newIDList.size()];
+	for(int i = 0; i<newIDList.size(); i++){
+	    id[i] = newIDList.get(i).toString();
+	}
+	
+	if(id.length==0 || metadataName.length==0){return new ArrayList();}
+	
+	detailList.add(alist);
+	detailList.add(id);
+	detailList.add(metadataName);
+	
+	return detailList;
+    }
+    
+    /*
+     * 	private ArrayList getEmptyMetadataDetail(ArrayList dataset, String[] id, String[] metadataName){
+     ArrayList detailList = new ArrayList();
+     return detailList;
+     }
+    */
+
+    public void generateAllPossibleGraph(ArrayList Namelist,String[]ids,String[] names,String condition){
+	//System.out.println("I AM HERE");
+    ArrayList dataList= Namelist;
+    String[] id = ids;
+    String[] metadataName = names;
+    
+	ArrayList alist = new ArrayList();
+	ArrayList detailList = new ArrayList();
+	ArrayList new_dataList = new ArrayList();
+	String[] idList;
+	String[] metadataNameList;
+	
+	//System.out.println("condition"+ condition);
+	//---------------------------------------------------------------------------------------------------------SS
+	//-----------------------------------------------------------------------SSSS
+	if(id.length==0 || metadataName.length==0){
+		generateEmptyGraph("SSSS","WORST",condition);
+		generateEmptyGraph("SSSS","BEST",condition);
+	}
+	
+	else{
+		new_dataList = transformDataList(dataList,id);
+		//WriteHTML("SSSS",new_dataList,id,metadataName,NORMAL);
+		WriteHTML("SSSS",new_dataList,id,metadataName,WORST,"Show completed graph",condition);
+		WriteHTML("SSSS",new_dataList,id,metadataName,BEST,"Show completed graph",condition);
+	}
+	//-----------------------------------------------------------------------SSSH
+	//System.out.println("SSSH 1");
+	detailList = getHideFullDocumentDetail(dataList,id,metadataName);
+	//System.out.println("SSSH 2");
+	if(detailList.size()==0){
+		generateEmptyGraph("SSSH","WORST",condition);
+		generateEmptyGraph("SSSH","BEST",condition);
+	}
+	else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+		new_dataList = transformDataList(alist,idList);
+		//WriteHTML("SSSH",new_dataList,idList,metadataNameList,NORMAL);
+		WriteHTML("SSSH",new_dataList,idList,metadataNameList,WORST,title4,condition);
+		WriteHTML("SSSH",new_dataList,idList,metadataNameList,BEST,title4,condition);
+	}
+	//-----------------------------------------------------------------------SSHS
+	//System.out.println("SSSS");
+	detailList = getHideEmptyDocumentDetail(dataList,id,metadataName);
+	//System.out.println("SSSS");
+	if(detailList.size()==0){
+		generateEmptyGraph("SSHS","WORST",condition);
+		generateEmptyGraph("SSHS","BEST",condition);
+		generateEmptyGraph("SSHH","WORST",condition);
+		generateEmptyGraph("SSHH","BEST",condition);
+	}
+	else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+		new_dataList = transformDataList(alist,idList);
+		//WriteHTML("SSHS",new_dataList,idList,metadataNameList,NORMAL);
+		WriteHTML("SSHS",new_dataList,idList,metadataNameList,WORST,title3,condition);
+		WriteHTML("SSHS",new_dataList,idList,metadataNameList,BEST,title3,condition);
+		//-----------------------------------------------------------------------SSHH
+		detailList = getHideFullDocumentDetail(alist,idList,metadataNameList);
+		if(detailList.size()==0){
+			generateEmptyGraph("SSHH","WORST",condition);
+			generateEmptyGraph("SSHH","BEST",condition);
+		}
+		else{
+			alist = (ArrayList)detailList.get(0);
+			idList = (String[])detailList.get(1);
+			metadataNameList = (String[])detailList.get(2);
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("SSHH",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("SSHH",new_dataList,idList,metadataNameList,WORST,title3+title4,condition);
+			WriteHTML("SSHH",new_dataList,idList,metadataNameList,BEST,title3+title4,condition);
+		}
+	}
+	
+	
+	//---------------------------------------------------------------------------------------------------------SH
+	ArrayList xList = new ArrayList(); 
+	String[] idListCopy;
+	String[] metadataNameListCopy;
+	
+	//-----------------------------------------------------------------------SHSS
+	detailList = getHideFullMetadataDetail(dataList,id,metadataName);
+	
+	if(detailList.size()==0){
+		generateEmptyGraph("SHSS","WORST",condition);
+		generateEmptyGraph("SHSS","BEST",condition);
+		
+		generateEmptyGraph("SHSH","WORST",condition);
+		generateEmptyGraph("SHSH","BEST",condition);
+		
+		generateEmptyGraph("SHHS","WORST",condition);
+		generateEmptyGraph("SHHS","BEST",condition);
+		
+		generateEmptyGraph("SHHH","WORST",condition);
+		generateEmptyGraph("SHHH","BEST",condition);
+	}
+	else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+	
+		xList = (ArrayList)alist.clone();
+		idListCopy = (String[]) idList.clone();
+		metadataNameListCopy = (String[])metadataNameList.clone();
+	
+		new_dataList = transformDataList(alist,idList);
+		//WriteHTML("SHSS",new_dataList,idList,metadataNameList,NORMAL);
+		WriteHTML("SHSS",new_dataList,idList,metadataNameList,WORST,title2,condition);
+		WriteHTML("SHSS",new_dataList,idList,metadataNameList,BEST,title2,condition);
+	
+	//-----------------------------------------------------------------------SHHS
+	detailList = getHideEmptyDocumentDetail((ArrayList)xList.clone(),(String[])idListCopy.clone(),(String[])metadataNameListCopy.clone());
+	//System.out.println("SHHS"+detailList.size());
+	if(detailList.size()==0){		
+		generateEmptyGraph("SHHS","WORST",condition);
+		generateEmptyGraph("SHHS","BEST",condition);
+		
+		generateEmptyGraph("SHHH","WORST",condition);
+		generateEmptyGraph("SHHH","BEST",condition);
+	}
+	else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+		//if(idList.length==0 || metadataName.length==0){}
+		new_dataList = transformDataList(alist,idList);
+		//WriteHTML("SHHS",new_dataList,idList,metadataNameList,NORMAL);
+		WriteHTML("SHHS",new_dataList,idList,metadataNameList,WORST,title2+title3,condition);
+		WriteHTML("SHHS",new_dataList,idList,metadataNameList,BEST,title2+title3,condition);
+		//step
+		//-----------------------------------------------------------------------SHHH
+		detailList = getHideFullDocumentDetail(alist,idList,metadataNameList);
+		if(detailList.size()==0){		
+			generateEmptyGraph("SHHH","WORST",condition);
+			generateEmptyGraph("SHHH","BEST",condition);
+		}
+		else{
+			alist = (ArrayList)detailList.get(0);
+			idList = (String[])detailList.get(1);
+			metadataNameList = (String[])detailList.get(2);
+	
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("SHHH",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("SHHH",new_dataList,idList,metadataNameList,WORST,title2+title3+title4,condition);
+			WriteHTML("SHHH",new_dataList,idList,metadataNameList,BEST,title2+title3+title4,condition);
+		}
+	}
+	
+	//-----------------------------------------------------------------------SHSH	
+	detailList = getHideFullDocumentDetail((ArrayList)xList.clone(),(String[])idListCopy.clone(),(String[])metadataNameListCopy.clone());
+		if(detailList.size()==0){		
+			generateEmptyGraph("SHSH","WORST",condition);
+			generateEmptyGraph("SHSH","BEST",condition);
+		}
+		else{
+			alist = (ArrayList)detailList.get(0);
+			idList = (String[])detailList.get(1);
+			metadataNameList = (String[])detailList.get(2);
+	
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("SHSH",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("SHSH",new_dataList,idList,metadataNameList,WORST,title2+title4,condition);
+			WriteHTML("SHSH",new_dataList,idList,metadataNameList,BEST,title2+title4,condition);
+		}
+	}
+	
+	//---------------------------------------------------------------------------------------------------------HS
+	ArrayList xList1 = new ArrayList(); 
+	String[] idListCopy1;
+	String[] metadataNameListCopy1;
+	
+	//-----------------------------------------------------------------------HSSS
+	detailList = getHideEmptyMetadataDetail(dataList,id,metadataName);
+	
+	if(detailList.size()==0){
+		generateEmptyGraph("HSSS","WORST",condition);
+		generateEmptyGraph("HSSS","BEST",condition);
+		
+		generateEmptyGraph("HSHS","WORST",condition);
+		generateEmptyGraph("HSHS","BEST",condition);
+		
+		generateEmptyGraph("HSHH","WORST",condition);
+		generateEmptyGraph("HSHH","BEST",condition);
+		
+		generateEmptyGraph("HSSH","WORST",condition);
+		generateEmptyGraph("HSSH","BEST",condition);
+	}
+	else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+	
+		xList1 = (ArrayList)alist.clone();
+		idListCopy1 = (String[]) idList.clone();
+		metadataNameListCopy1 = (String[])metadataNameList.clone();
+	
+		new_dataList = transformDataList(alist,idList);
+		//WriteHTML("HSSS",new_dataList,idList,metadataNameList,NORMAL);
+		WriteHTML("HSSS",new_dataList,idList,metadataNameList,WORST,title1,condition);
+		WriteHTML("HSSS",new_dataList,idList,metadataNameList,BEST,title1,condition);
+	
+		//-----------------------------------------------------------------------HSHS
+		detailList = getHideEmptyDocumentDetail((ArrayList)xList1.clone(),(String[])idListCopy1.clone(),(String[])metadataNameListCopy1.clone());
+		if(detailList.size()==0){
+			generateEmptyGraph("HSHS","WORST",condition);
+			generateEmptyGraph("HSHS","BEST",condition);
+			
+			generateEmptyGraph("HSHH","WORST",condition);
+			generateEmptyGraph("HSHH","BEST",condition);
+		}
+		else{
+			alist = (ArrayList)detailList.get(0);
+			idList = (String[])detailList.get(1);
+			metadataNameList = (String[])detailList.get(2);
+			
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("HSHS",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("HSHS",new_dataList,idList,metadataNameList,WORST,title1+title3,condition);
+			WriteHTML("HSHS",new_dataList,idList,metadataNameList,BEST,title1+title3,condition);
+	
+			//-----------------------------------------------------------------------HSHH
+			detailList = getHideFullDocumentDetail(alist,idList,metadataNameList);
+			if(detailList.size()==0){		
+				generateEmptyGraph("HSHH","WORST",condition);
+				generateEmptyGraph("HSHH","BEST",condition);
+			}
+			else{
+				alist = (ArrayList)detailList.get(0);
+				idList = (String[])detailList.get(1);
+				metadataNameList = (String[])detailList.get(2);
+	
+				new_dataList = transformDataList(alist,idList);
+				//WriteHTML("HSHH",new_dataList,idList,metadataNameList,NORMAL); 
+				WriteHTML("HSHH",new_dataList,idList,metadataNameList,WORST,title1+title3+title4,condition); 
+				WriteHTML("HSHH",new_dataList,idList,metadataNameList,BEST,title1+title3+title4,condition); 
+			}
+		}
+	
+	//-----------------------------------------------------------------------HSSH
+		detailList = getHideFullDocumentDetail((ArrayList)xList1.clone(),(String[])idListCopy1.clone(),(String[])metadataNameListCopy1.clone());
+		if(detailList.size()==0){
+			generateEmptyGraph("HSSH","WORST",condition);
+			generateEmptyGraph("HSHS","BEST",condition);
+		}
+		else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+	
+		new_dataList = transformDataList(alist,idList);
+		//WriteHTML("HSSH",new_dataList,idList,metadataNameList,NORMAL);
+		WriteHTML("HSSH",new_dataList,idList,metadataNameList,WORST,title1+title4,condition);
+		WriteHTML("HSSH",new_dataList,idList,metadataNameList,BEST,title1+title4,condition);
+		}
+	}
+	
+	//---------------------------------------------------------------------------------------------------------HH
+	ArrayList xList2 = new ArrayList(); 
+	String[] idListCopy2;
+	String[] metadataNameListCopy2;
+	
+	//-----------------------------------------------------------------------HHSS
+	detailList = getHideEmptyMetadataDetail(dataList,id,metadataName);
+	if(detailList.size()==0){
+		generateEmptyGraph("HHSS","WORST",condition);
+		generateEmptyGraph("HHSS","BEST",condition);
+		
+		generateEmptyGraph("HHHS","WORST",condition);
+		generateEmptyGraph("HHHS","BEST",condition);
+		
+		generateEmptyGraph("HHHH","WORST",condition);
+		generateEmptyGraph("HHHH","BEST",condition);
+		
+		generateEmptyGraph("HHSH","WORST",condition);
+		generateEmptyGraph("HHSH","BEST",condition);
+	}
+	else{
+		alist = (ArrayList)detailList.get(0);
+		idList = (String[])detailList.get(1);
+		metadataNameList = (String[])detailList.get(2);
+	
+		detailList = getHideFullMetadataDetail(alist,idList,metadataNameList);
+		//System.out.println(detailList.size());
+		if(detailList.size()==0){
+			generateEmptyGraph("HHSS","WORST",condition);
+			generateEmptyGraph("HHSS","BEST",condition);
+			
+			generateEmptyGraph("HHHS","WORST",condition);
+			generateEmptyGraph("HHHS","BEST",condition);
+			
+			generateEmptyGraph("HHHH","WORST",condition);
+			generateEmptyGraph("HHHH","BEST",condition);
+			
+			generateEmptyGraph("HHSH","WORST",condition);
+			generateEmptyGraph("HHSH","BEST",condition);
+		}
+		else{
+			//System.out.println("bad"+detailList.size());
+			alist = (ArrayList)detailList.get(0);
+			//System.out.println("bad");
+			idList = (String[])detailList.get(1);
+			//System.out.println("bad");
+			metadataNameList = (String[])detailList.get(2);
+			//System.out.println("bad");
+		
+			xList2 = (ArrayList)alist.clone();
+			idListCopy2 = (String[]) idList.clone();
+			metadataNameListCopy2 = (String[])metadataNameList.clone();
+	
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("HHSS",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("HHSS",new_dataList,idList,metadataNameList,WORST,title1+title2,condition);
+			WriteHTML("HHSS",new_dataList,idList,metadataNameList,BEST,title1+title2,condition);
+		
+	
+		//---------------------------------------------------------------------- HHSH	
+		detailList = getHideFullDocumentDetail((ArrayList)xList2.clone(),(String[])idListCopy2.clone(),(String[])metadataNameListCopy2.clone());
+		if(detailList.size()==0){
+			generateEmptyGraph("HHSH","WORST",condition);
+			generateEmptyGraph("HHSH","BEST",condition);
+		}
+		else{
+			alist = (ArrayList)detailList.get(0);
+			idList = (String[])detailList.get(1);
+			metadataNameList = (String[])detailList.get(2);
+	
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("HHSH",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("HHSH",new_dataList,idList,metadataNameList,WORST,title1+title2+title4,condition);
+			WriteHTML("HHSH",new_dataList,idList,metadataNameList,BEST,title1+title2+title4,condition);
+		}
+		//----------------------------------------------------------------------HHHS	
+		detailList = getHideEmptyDocumentDetail((ArrayList)xList2.clone(),(String[])idListCopy2.clone(),(String[])metadataNameListCopy2.clone());
+		if(detailList.size()==0){
+			generateEmptyGraph("HHHS","WORST",condition);
+			generateEmptyGraph("HHHS","BEST",condition);
+			
+			generateEmptyGraph("HHHH","WORST",condition);
+			generateEmptyGraph("HHHH","BEST",condition);
+		}
+		else{
+			alist = (ArrayList)detailList.get(0);
+			idList = (String[])detailList.get(1);
+			metadataNameList = (String[])detailList.get(2);
+	
+			new_dataList = transformDataList(alist,idList);
+			//WriteHTML("HHHS",new_dataList,idList,metadataNameList,NORMAL);
+			WriteHTML("HHHS",new_dataList,idList,metadataNameList,WORST,title1+title2+title3,condition);
+			WriteHTML("HHHS",new_dataList,idList,metadataNameList,BEST,title1+title2+title3,condition);
+	
+			//----------------------------------------------------------------------HHHH
+			detailList = getHideFullDocumentDetail((ArrayList)alist.clone(),(String[])idList.clone(),(String[])metadataNameList.clone());
+			if(detailList.size()==0){
+				generateEmptyGraph("HHHH","WORST",condition);
+				generateEmptyGraph("HHHH","BEST",condition);
+			}
+			else{
+				alist = (ArrayList)detailList.get(0);
+				idList = (String[])detailList.get(1);
+				metadataNameList = (String[])detailList.get(2);
+	
+				new_dataList = transformDataList(alist,idList);
+				//WriteHTML("HHHH",new_dataList,idList,metadataNameList,NORMAL);
+				WriteHTML("HHHH",new_dataList,idList,metadataNameList,WORST,title1+title2+title3+title4,condition);
+				WriteHTML("HHHH",new_dataList,idList,metadataNameList,BEST,title1+title2+title3+title4,condition);
+			}
+		}
+	}
+	}
+    }
+    
+    private ArrayList transformDataList(ArrayList list, String[] ids){
+	
+	//System.out.println("warning2");
+	ArrayList wholeList = new ArrayList();
+	
+	for(int i = 0; i< ids.length; i++){
+	    ArrayList idList = new ArrayList();
+	    for(int j = 0; j<list.size();j++){
+		int[] datarows = (int[]) list.get(j);
+		idList.add(new Integer (datarows[i]));
+	    }
+	    wholeList.add(idList);
+	}
+	
+	for(int i = 0; i< wholeList.size(); i++){
+	    ArrayList alist = (ArrayList)wholeList.get(i);
+	    int[] rows = new int[alist.size()];
+	    for(int j = 0; j< alist.size(); j++){
+		rows[j] = ((Integer)alist.get(j)).intValue();
+	    }
+	    wholeList.remove(i);
+	    wholeList.add(i,rows);
+	}
+	//System.out.println("warning3");
+	return wholeList;
+	
+    }
+    
+    private void generateEmptyGraph(String fileName,String condition,String suffix){
+    	String cases = condition; 
+    	String collectionFolder = mds.getCollectionName();
+    	
+    	 String suf = suffix;
+         if(!suffix.equalsIgnoreCase("dublin")){
+         	suf = "other";
+         }
+         
+    	//System.out.println(fileName+cases+" err");
+    	try{
+    	//FileWriter fstream = new FileWriter(destination+collectionFolder+"/"+suffix+"_"+fileName+"_"+cases+".html");
+        FileWriter fstream = new FileWriter(collectionFolder+"/"+suf+"_"+fileName+"_"+cases+".html");
+	    BufferedWriter out = new BufferedWriter(fstream);
+	    out.write("<!-- This comment keeps IE6/7 in the reliable quirks mode -->\r\n");
+	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
+	    out.write("<html>\r\n");
+	    out.write("<head>\r\n<title> No Available Chart</title>\r\n");
+	    
+	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+	    //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
+	   
+	    //out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
+	    out.write("</head>\r\n");
+	    out.write("<p><a href=\" Overall.html \">Summary</a></p>");
+	    out.write("<body>\r\n");
+	    out.write("<p>No data available to render chart.</p>\r\n");
+	    out.write("<p>Reason: Document number is zero or Metadata element number is zero </p>\r\n");
+	    out.close();
+    	}catch(Exception e){}
+    	
+    }
+    private void WriteHTML(String fileName, ArrayList dataset, String[] ids, String[] metadataName, String condition, String title, String suffix){
+    	
+    	int blueDot = 0;
+    	String cases = condition; 
+    	
+        String suf = suffix;
+        if(!suffix.equalsIgnoreCase("dublin")){
+        	suf = "other";
+        }
+        
+	try{
+
+		String str = sdf.format(cl.getTime());
+		DataMaker dmx = new DataMaker(mds);
+		String collectionFolder = mds.getCollectionName();
+		int cols = (metadataName.length +2 )*100;
+	    FileWriter fstream = new FileWriter(collectionFolder+"/"+suf+"_"+fileName+"_"+cases+".html");
+		//FileWriter fstream = new FileWriter(destination+collectionFolder+"/"+suffix+"_"+fileName+"_"+cases+".html");
+
+	    BufferedWriter out = new BufferedWriter(fstream);
+	    out.write("<!-- This comment keeps IE6/7 in the reliable quirks mode -->\r\n");
+	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
+	    out.write("<html>\r\n");
+	    out.write("<head>\r\n<title>"+title+"</title>\r\n");
+	    
+	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+	    out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
+	   
+	    out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
+	    out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js\"></script>\r\n");
+	    out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/event/event-min.js\"></script>\r\n");
+	    out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js\"></script>\r\n");
+	    //out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");
+	    // <script src="http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js"></script>
+	    //<script src="http://yui.yahooapis.com/2.4.1/build/event/event-min.js"></script> 
+	    // <script src="http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js"></script>
+	    
+	    out.write("</head>\r\n");
+	    out.write ("<p><a href=\" Overall.html \">Summary</a></p>");
+	    out.write("<body id=\""+mds.getCollectionName()+"\" onLoad=\"reconfig()\">\r\n");
+	    
+	    out.write("<div id=\"container\">\r\n");
+	    out.write("<div class=\"tableContainer\">\r\n");
+	 
+	    out.write ("<table cellspacing=\"0\">\r\n");
+
+	    
+	    out.write ("<thead>\r\n");
+	    out.write ("<tr>\r\n");
+		out.write("<td class=\"qh\">Info\r\n");
+		out.write("<td class=\"qh\">URL\r\n");
+		//System.out.println("step1");
+	    for(int a = 0; a< metadataName.length; a++){
+	    	out.write("<td>"+ metadataName[a]+"\r\n");
+	    }
+	    //System.out.println("step2");
+	    out.write ("</thead>\r\n<tfoot>\r\n<tr>\r\n");
+	    
+	    out.write("<td class=\"qh\">&nbsp;\r\n");
+	    out.write("<td class=\"qh\">&nbsp;\r\n");
+	    for(int a = 0; a< metadataName.length; a++){
+	    	//System.out.println(a+metadataName[a]);
+	    	out.write("<td>"+ dm.Mean(metadataName[a])+"%\r\n");
+	    }
+	    //System.out.println("step3");
+	    out.write ("</tfoot>\r\n<tbody>\r\n");
+	    
+	    if(cases.equals("normal")){
+	    	for(int i = ids.length; i>0; i--){
+	    		out.write ("<tr>");
+	    		int[] datarows = (int[])dataset.get(i-1);
+
+	    		for(int j = 0; j<datarows.length; j++){
+		    
+	    			if(datarows[j]==1){
+	    				out.write ("<td class=\"b\">");
+	    				blueDot++;
+	    			}
+	    			else {
+	    			 	out.write ("<td>&nbsp;");
+	    			}
+	    		}
+	    	}
+	    }
+	    else{
+	    	ArrayList idList = new ArrayList();
+	    	for(int i = 0; i<ids.length;i++){
+	    		idList.add(ids[i]);
+	    	}
+	    	
+	    	
+	    	HashMap hp = new HashMap();
+	    	
+	    	for(int i = ids.length; i>0; i--){
+	    		String idValue = ids[i-1];
+	    		int dots = 0;
+	    		int[] datarows = (int[])dataset.get(i-1);
+	    		for(int j = 0; j<datarows.length; j++){
+	    			if(datarows[j]==1){
+	    				dots++;
+	    			}	
+	    		}
+	    		hp.put(idValue,new Integer(dots));
+
+	    	}
+	    	ArrayList alist = dmx.sortMap(hp);
+	    	String[] idIntValue = new String[alist.size()]; 
+			for(int i = 0; i< alist.size(); i++){
+	    		Map.Entry entry = (Map.Entry) alist.get(i);
+	    		String idElement = ((String) entry.getKey());
+	    		idIntValue[i] = idElement;
+			}
+			
+	    if(cases.equals("worst")){
+	    	//System.out.println("step4");
+			for(int i = 0; i<idIntValue.length; i++){
+	    		int value = idList.indexOf(idIntValue[i]);
+	    		int[] datarows = (int[])dataset.get(value);
+	    		//System.out.println("step5");
+	    		out.write ("<tr id=\""+idIntValue[i].substring(4)+"\">\r\n");
+	    		out.write("<td class=\"E\" onclick=\"GD(this)\">&nbsp;\r\n");
+	    		//out.write("<td  class=\"qh\" onclick=\"GX(this)\">URL\r\n");
+	    		out.write("<td  class=\"qh\" onclick=\"GX(this)\">open\r\n");
+	    		for(int j = 0; j<datarows.length; j++){
+	    			//System.out.println("step6");
+	    			if(datarows[j]==1){
+	    				out.write ("<td class=\"b\">\r\n");
+	    				blueDot++;
+	    			}
+	    			else {
+
+	    				 out.write ("<td class=\"w\">\r\n");
+	    			}
+	    		}
+	    		//System.out.println("step7");
+	    		//out.write ("</tr>\r\n");
+			}
+	    }
+	    
+	    if(cases.equals("best")){
+			for(int i = idIntValue.length; i>0; i--){
+	    		int value = idList.indexOf(idIntValue[i-1]);
+	    		int[] datarows = (int[])dataset.get(value);
+
+	    		out.write ("<tr id=\""+idIntValue[i-1].substring(4)+"\">\r\n");
+	    		out.write("<td class=\"E\" onclick=\"GD(this)\">&nbsp;\r\n");
+	    		//out.write("<td class=\"qh\" onclick=\"GX(this)\">URL\r\n");
+	    		out.write("<td class=\"qh\" onclick=\"GX(this)\">open\r\n");
+	    		for(int j = 0; j<datarows.length; j++){
+		    
+	    			if(datarows[j]==1){
+	    				out.write ("<td class=\"b\">\r\n");
+	    				blueDot++;
+	    			}
+	    			else {
+	    				out.write ("<td class=\"w\">\r\n");
+	    			}
+	    		}
+	    		//out.write("<td class=\"E\" onmousemove=\"GD(this)\">&nbsp;\r\n");
+			}
+	    }
+	}
+	    out.write ("</tbody>\r\n");
+
+	    out.write ("</table>\r\n</div></div>\r\n");
+
+	    int t1 = ids.length;
+	    HashMap hpd = mds.getMetadataSetMap();
+	    int t2 = hpd.size();
+	    int t3 = metadataName.length;
+
+	    int t4 = t1*t3;
+	    out.write("<table>\r\n<tbody class=\"table1\">");
+	    out.write("<tr>\r\n");
+	    out.write("<td class=\"bfont\">This subset shows "+t1+" out of "+dm.getDocNum()+" documents");
+	    out.write("<td class=\"bfont\">"+blueDot+" out of "+(dm.getDocNum()*t3)+" metadata items  are defined");
+	    out.write("<tr>\r\n");
+	    out.write("<td class=\"bfont\">This subset shows "+t3+" out of "+mds.metadataNameList.size()+" metadata elements");
+	    out.write("<td class=\"bfont\">Subset completeness: "+dm.round((double)(blueDot*100/t4),5)+"%");
+	    //out.write ("<p align=center> <a href=\" Overall.html \">Overall Statistics</a></p>");
+	    out.write("</table>\r\n");
+	    out.write ("<p> <a href=\"Overall.html \">Summary</a></p>");
+	    out.write ("</body></html>");
+	    //Close the output stream
+	    out.close();
+	}catch (Exception e){//Catch exception if any
+	
+	    System.err.println("Error: " + e.getMessage());
+	}
+    }
+
+    
+    public void generateOverallStatisticsPage(HashMap MetadataSetMap){
+    	//System.out.println("overall start");
+    	String fileName = "Overall";
+
+    	ArrayList wholeList = new ArrayList();
+    	HashMap hp = mds.getMetadataSetMap();
+    	Collection c = hp.values();
+    	Iterator i = c.iterator();
+    	int counter = 0;
+    	String[][] MetadataData = new String[c.size()][2];
+    	while(i.hasNext()){
+    		MetadataSet mds  = (MetadataSet)i.next();
+    		wholeList.add(mds);
+    		ArrayList newMDS  = new ArrayList();
+    		newMDS.add(mds);
+    		
+    		MetadataData[counter][0] = mds.getName();
+    		MetadataData[counter][1] = dm.getSingleMetadataSetCompleteness(newMDS)+"%";
+    		//System.out.println(MetadataData[counter][0]+MetadataData[counter][1]);
+    		counter++;
+    	}
+
+    	try{
+    	    //printWriter.write("<!-- generating all possible page-->");
+    	    //printWriter.flush();
+    	    
+    		String str = sdf.format(cl.getTime());
+    		String collectionFolder = mds.getCollectionName();
+
+    	    //FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
+    		FileWriter fstream = new FileWriter("/home/cc108/MRWks1/describeMessenger/"+collectionFolder+"/"+fileName+".html");
+    	    BufferedWriter out = new BufferedWriter(fstream);
+    	    
+    	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+    	    out.write("<html>\r\n");
+    	    out.write("<head><title>Summary</title>\r\n");
+    	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+    	    //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
+    	    out.write("<style type=\"text/css\">\r\n");
+    	    out.write(".tam{height:20; text-align:right}\r\n");
+    	    out.write("th{height:20; text-align:left}\r\n");
+    	    out.write("body{font-family: Arial;}\r\n");
+    	    out.write("</style>\r\n");    	    
+    	    out.write("<script type=\"text/javascript\" src=\"../script/status3.js\"></script>\r\n");
+    	    out.write("</head>\r\n");
+    	    
+    	    out.write("<body>\r\n");
+    	    out.write ("<td> <div style=\"float:left;\"> <a href=\"http://www.nzdl.org/greenstone3/mat\">Mat Home</a></div>");
+    	    out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
+    	    // out.write("<p align=\"right\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Short feedback survey about the Mat tool</a></p>");
+    	    //out.write("<p> <a href=\"http://www.nzdl.org/greenstone3/mat\">Mat Home</a></p>");
+    	    out.write("<h3 align=\"center\">Summary</h3>\r\n");
+
+    	    out.write("<table border=1 align=\"center\">\r\n");
+    	    out.write("<colgroup width=\"300\" span=\"2\">\r\n");
+
+    	    /*
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>Collection: </th>\r\n");
+    	    out.write("<td class=\"tam\">"+mds.getCollectionName()+"\r\n");
+    	    out.write("</tr>\r\n");
+    	    */
+    	    
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>OAI URL: </th>\r\n");
+    	    if(mds.getOAIURL().length()>50){
+    	    	out.write("<td class=\"tam\"><font size=\"2px\"><a href=\""+mds.getOAIURL()+"\">"+mds.getOAIURL().substring(0,47)+"....</a></font>\r\n");
+    	    }
+    	    else{
+    	    	out.write("<td class=\"tam\"><font size=\"2px\"><a href=\""+mds.getOAIURL()+"\">"+mds.getOAIURL()+"</a></font>\r\n");
+    	    }
+    	    out.write("</tr>\r\n");
+    	    
+    	    /*
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>Metadata Prefix:\r\n");
+    	    out.write("<td class=\"tam\">"+mds.getOaiPrefix()+"\r\n");
+    	    out.write("</tr>\r\n");
+    	    */
+    	    
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>Number of Records:\r\n");
+    	    out.write("<td class=\"tam\">"+dm.getDocNum()+"\r\n");
+    	    out.write("</tr>\r\n");
+    	    /*
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>Number of Metadata:\r\n");
+    	    out.write("<td class=\"tam\">"+mds.getMetadataSetMap().size()+"\r\n");
+    	    out.write("</tr>\r\n");
+    	    
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>Overall Metadata Completeness:\r\n");
+    	    out.write("<td class=\"tam\">"+dm.getSingleMetadataSetCompleteness(wholeList)+"%\r\n");
+    	    out.write("</tr>\r\n</table>");
+    	    */
+    	    out.write("<table border=1 align=\"center\">\r\n");
+    	    out.write("<colgroup width=\"300\" span=\"2\">\r\n");
+    	    out.write("<tr>\r\n");
+    	    out.write("<th>Metadata:\r\n");
+    	    out.write("<td class=\"tam\"><b>Completeness</b>\r\n");
+    	    out.write("</tr><br>\r\n");
+
+    	    for(int a = 0; a<MetadataData.length; a++){
+    	    	out.write ("<tr>\r\n");
+    	    	if(MetadataData[a][0].equalsIgnoreCase("dublin")){
+    	    		out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet1+"</a>");
+    	    	}
+    	    	else if (MetadataData[a][0].equalsIgnoreCase("extracted")){
+    	    		out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet2+"</a>");
+    	    	}
+    	    	else{
+    	    		out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+MetadataData[a][0]+"</a>");
+    	    	}
+    	    	//out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+MetadataData[a][0] +"</a>");
+    	    	out.write ("<td class=\"tam\"> "+MetadataData[a][1]);
+    	    	out.write ("</tr>\r\n");
+    	    }
+    	    out.write ("</table>");
+    	    out.write("<br>\r\n");
+    	    out.write("<FORM  name=\"test\" onsubmit=\"checkStatus()\" action=\"\">");
+    	    out.write("<table border=1 align=\"center\">\r\n");
+    	    out.write ("<colgroup width=\"606\" span=\"1\">\r\n");
+    	    out.write("<tr>\r\n<th>Customize Visualization");
+    	    out.write("<tr>\r\n<td><LABEL FOR=\"H1\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H1\">Hide Empty Metadata Elements</LABEL>");
+    	    out.write("<tr>\r\n<td><LABEL FOR=\"H2\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H2\">Hide Completed Metadata Elements</LABEL>");
+    	    out.write("<tr>\r\n<td><LABEL FOR=\"H3\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H3\">Hide Documents with Empty Metadata Elements</LABEL>");
+    	    out.write("<tr>\r\n<td><LABEL FOR=\"H4\"><INPUT align=\"left\" TYPE=\"checkbox\" ID=\"H4\">Hide Documents with  Completed Metadata Elements</LABEL>");
+    	    out.write("<tr>\r\n<th>Metadata: ");
+    	    
+    	    ///////////////////////////////////////
+    	    
+    	    //out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked>Dublin Core</LABEL>");
+    	    //out.write("<tr>\r\n<td><LABEL FOR=\"C2\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C2\" checked>Extracted</LABEL>");
+    	    //out.write("<tr>\r\n<td><LABEL FOR=\"C3\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C3\" checked >Both</LABEL>");
+    	    
+    	    if(MetadataData.length==1){
+    	        //out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked>"+MetadataData[0][0]+"</LABEL>");
+    			if(MetadataData[0][0].equalsIgnoreCase("dublin")){
+    				out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked> Dublin Core </LABEL>");
+    			}
+    			else {
+    				out.write("<tr>\r\n<td><LABEL FOR=\"C4\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C4\" checked>"+MetadataData[0][0]+"</LABEL>");
+    			}
+    	    }
+    	    else{
+    	    	for(int a = 0; a<MetadataData.length; a++){
+    	    		if(a==0){
+    	    			if(MetadataData[a][0].equalsIgnoreCase("dublin")){
+    	    				out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\" checked>Dublin Core</LABEL>");
+    	    			}
+    	    			else {
+    	    				out.write("<tr>\r\n<td><LABEL FOR=\"C4\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C4\" checked>"+MetadataData[a][0]+"</LABEL>");
+    	    			}
+    	    		}
+    	    		else{
+    	    			if(MetadataData[a][0].equalsIgnoreCase("dublin")){
+    	    				out.write("<tr>\r\n<td><LABEL FOR=\"C1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C1\">"+MetadataData[a][0]+"</LABEL>");
+    	    			}
+    	    			else{
+    	    				out.write("<tr>\r\n<td><LABEL FOR=\"C4\"><INPUT align=\"left\" TYPE=\"radio\" name = \"col\" ID=\"C4\">"+MetadataData[a][0]+"</LABEL>");
+    	    			}
+    	    			  
+    	    		}
+    	    	}
+    	    }
+    	    
+    	    ////////////////////////////////////////////////////////////////////////////////////////////////
+    	    out.write("<tr>\r\n<th>Order By Completeness : ");
+    	    out.write("<tr>\r\n<td><LABEL FOR=\"R1\"><INPUT align=\"left\" TYPE=\"radio\" name = \"order\" ID=\"R1\">Best Case to Worst Case</LABEL>");
+    	    out.write("<tr>\r\n<td><LABEL FOR=\"R2\"><INPUT align=\"left\" TYPE=\"radio\" name = \"order\" ID=\"R2\" checked >Worst Case to Best Case</LABEL>");
+    	    out.write("</table><p align=\"center\"><INPUT TYPE=\"button\" VALUE=\"Show Visualization\" onClick=\"checkStatus()\"> </FORM>");
+    	    //out.write("<p align=\"right\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Short feedback survey about the Mat tool</a></p>");
+    	    out.write("<p align=\"center\">"+str+"</p>");
+    	    //out.write("<p align=\"left\">Comments to <a href=\"http://www.cs.waikato.ac.nz/~daven/\">Dave Nichols</a></p>");
+    	    out.write("</body></html>");
+    	    //Close the output stream
+    	    out.close();
+    	    fstream.close();
+    	}catch (Exception e){//Catch exception if any
+    		//System.out.println("overall");
+    	    System.err.println("Error: " + e.getMessage());
+    	}
+	    //printWriter.write("<!-- generating all possible page-->");
+	    //printWriter.flush();
+    	//System.out.println("overall ends");
+    	
+    }
+
+    public void generateMetadataSetDetailPage(HashMap MetadataSetMap){
+    	
+    Collection c = MetadataSetMap.values();
+    Iterator i = c.iterator();
+    while(i.hasNext()){
+    	MetadataSet mds = (MetadataSet)i.next();
+    	
+    }
+    }
+    
+    
+    public void WriteMetadataSetDetailHTML(MetadataSet mdset){
+    	String fileName = mdset.getName();
+    	DataMaker dmx = new DataMaker(mds);
+    	//DataMaker dmx = dm;
+    	//System.out.println("set start");
+    	try{
+
+    		String str = sdf.format(cl.getTime());
+    		String collectionFolder = mds.getCollectionName();
+    	    FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
+    		//FileWriter fstream = new FileWriter(destination+collectionFolder+"/"+fileName+".html");
+    	    BufferedWriter out = new BufferedWriter(fstream);
+    	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+    	    out.write("<html>\r\n");
+    	    out.write("<head>\r\n<title>Metadata Detail</title>\r\n");
+    	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+    	    out.write("<style type=\"text/css\">\r\n");
+    	    out.write("td{height:20;text-align:right;}\r\n");
+    	    out.write("th{height:20;text-align:left;}\r\n");
+    	    out.write("body{font-family: Arial;}\r\n");
+    	    out.write("</style>\r\n");
+    	    out.write( "</head>\r\n");
+
+    	    out.write ("<body>\r\n");
+    	    out.write ("<p> <a href=\" Overall.html \">Summary</a></p>");
+    	  	if(fileName.equalsIgnoreCase("dublin")){
+	    		//out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet1+"</a>");
+	    		out.write ("<h3 align=\"center\">Metadata Detail: "+metadataSet1+"</h3>\r\n");
+	    	}
+	    	else if (fileName.equalsIgnoreCase("extracted")){
+	    		//out.write ("<th><a href =\""+MetadataData[a][0]+".html\">"+metadataSet2+"</a>");
+	    		out.write ("<h3 align=\"center\">Metadata Detail: "+metadataSet2+"</h3>\r\n");
+	    	}
+	    	else{
+	    		out.write ("<h3 align=\"center\">Metadata Detail: "+fileName+"</h3>\r\n");
+	    	}
+    	    out.write ("<table border=\"1\" align=\"center\">\r\n");
+    	    out.write ("<colgroup width=\"200\" span=\"2\">\r\n");
+
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>Elements:\r\n");
+    	    out.write ("<td><b>Completeness</b>\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		ArrayList elementList = mdset.getIndexsList();
+    		HashMap hp = new HashMap();
+    		int num = elementList.size();
+    		for(int i = 0; i<num; i++){
+    			String elementName = (String)elementList.get(i);
+    			Double elementValue = new Double(dmx.Mean(elementName));
+    			hp.put(elementName, elementValue);
+    		}
+    		
+    		elementList = new ArrayList();
+    		elementList = dmx.sortMap(hp);
+    		num = elementList.size();
+    		for(int i = 0; i<num; i++){
+        		Map.Entry entry = (Map.Entry) elementList.get(i);
+        		String elementName = (String) entry.getKey();
+        	    out.write ("<tr>\r\n");
+        	    out.write ("<th><a href=\""+ elementName +".html\">"+elementName+"</a>\r\n");
+        	    out.write ("<td>"+ dmx.Mean(elementName)+"%\r\n");
+        		out.write ("</tr>\r\n");
+    		}
+    	    
+    	    out.write("</table>\r\n");
+    	    
+    	    out.write ("<p align=\"center\"> <a href=\" Overall.html \">Summary</a></p>");
+    	    out.write("<p align=\"center\">"+str+"</p>");
+    	    
+    	    //out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Overall Statistics</a></div>");
+    	    //out.write("<div style=\"float:right;\">"+str+"</div></td>");
+    	    //<td><div   style="float:left;">test</div><div   style="float:right;">test</div></td>
+    	    out.write ("</body></html>\r\n");
+    	    //Close the output stream
+    	    out.close();
+    	}catch (Exception e){//Catch exception if any
+    		//System.out.println("set");
+    	    System.err.println("Error: " + e.getMessage());
+    	}
+    	//System.out.println("set ends");
+        }
+    
+    public void generateMetadataElementDetailPage(MetadataSet mds){
+    	
+    	ArrayList nameList = mds.getIndexsList();
+    	for(int i = 0; i<nameList.size();i++){
+    		WriteMetadataElementDetailHTML((String)nameList.get(i),mds.getName());
+    	}
+    }
+    
+    public void WriteMetadataElementDetailHTML(String name, String linkName){
+    	
+    	String fileName = name;
+    	DataMaker dmx = new DataMaker(this.mds);
+
+    	//System.out.println("detail start");
+    	
+    	try{
+    		//String str = sdf.format(cl.getTime());
+    		String collectionFolder = mds.getCollectionName();
+    	    FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
+    		//FileWriter fstream = new FileWriter(destination+collectionFolder+"/"+fileName+".html");
+    	    BufferedWriter out = new BufferedWriter(fstream);
+    	    //System.out.println("step0" + fileName);
+    	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+    	    out.write ("<html>\r\n");
+    	    out.write("<head>\r\n<title>Metadata Element Detail</title>\r\n");
+    	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+    	    out.write("<style type=\"text/css\">\r\n");
+    	    out.write("td{height:20; text-align:left;}\r\n");
+    	    out.write(".tam{height:20; text-align:center}\r\n");
+    	    out.write("th{height:20; text-align:left;}\r\n");
+    	    out.write("body{font-family: Arial;}\r\n");
+    	    out.write("</style>\r\n");
+    	    out.write("<script type=\"text/javascript\" src=\"http://www.nzdl.org/greenstone3/mat/script/status3.js\"></script>");
+    	    out.write("</head>\r\n");
+        	out.write("<body>\r\n");
+    	    out.write("<p><a href=\" Overall.html \">Summary</a>");
+    	    out.write("&raquo;");
+    	    //out.write("<a href=\""+linkName+".html\">Metadata Set Detail("+linkName+")</a></p>");
+    	    
+    	    
+    	    ////////////////////////////////////////////////////////////////////////////////////
+    	  	if(linkName.equalsIgnoreCase("dublin")){
+    	  		out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet1+")</a></p>"); 
+	    		//out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet1+"</h1>\r\n");
+	    	}/*
+	    	else if (linkName.equalsIgnoreCase("extracted")){
+	    		out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet2+")</a></p>"); 
+	    		//out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet2+"</h1>\r\n");
+	    	}*/
+	    	else{
+	    		out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+linkName+")</a></p>"); 	  
+	    	}
+    	  	///////////////////////////////////////////////////////////////////////////////////////////////
+    	  	if(name.startsWith("dc.")){
+    	  		int dot = name.lastIndexOf('.');
+    	  		dot++;
+    	  		String nameReplace = name.substring(dot);
+    	  		if(url.containsKey(nameReplace)){
+    	  		   out.write ("<h3 align=\"center\">Metadata Element Detail:<a href=\""+ url.get(nameReplace) +"\">"+ name +"</a></h3>\r\n");
+    	  		}
+    	  		else{
+    	  			out.write ("<h3 align=\"center\">Metadata Element Detail: "+ name +"</a></h3>\r\n");
+    	  		}
+    	  	}
+    	    
+    	  	else{
+   	  		 out.write ("<h3 align=\"center\">Metadata Element Detail: "+ name +"</h3>\r\n");
+    	  	}
+    	  	
+    	  	/*
+    	  	 * 1. retrieve all IDs from archivedir
+    	  	 * 2. retrieve all IDs from 
+    	  	 * 
+    	  	 */
+    	  	/////////////////////////////////////////////////////////////
+    	  	
+    	  	HashMap internalIDMap = dm.getInternalIdentifier(fileName);	
+    	  	///////////////////////////////////////////////////////////
+    	    out.write ("<table border=\"1\" align=\"center\" width=1000>\r\n");
+    	    out.write ("<colgroup width=\"500\" span=\"2\">\r\n");
+    	    
+    	    //System.out.println("step1");
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>Total Number of Documents\r\n");
+    	    
+    	    out.write ("<td class=\"tam\">"+dm.getDocNum()+"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step2");
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>Unique Values\r\n");
+    	    //System.out.println(name);
+    	    out.write ("<td class=\"tam\">"+dmx.getDistinctNumber(name)+"\r\n");
+    	    //System.out.println(name);
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step3");
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>Total times element used\r\n");
+    	    out.write ("<td class=\"tam\">"+dmx.getFrequency(name) +"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step4");
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>No. of records containing element\r\n");
+    	    out.write ("<td class=\"tam\"> "+dmx.getDocumentUsedElement(name)+"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step5");
+    	    out.write ("<tr>\r\n");
+    	    //out.write ("<th title = \"The completeness means the arithmetic average \">Completeness\r\n");
+    	    double percentage = dmx.Mean(name);
+    	    if(percentage<100){
+    	    	out.write ("<th title = \"The completeness means the arithmetic average \"> <div style=\"float:left;\"> Completeness</div>");
+    	    	out.write ("<div style=\"float:right;\"><a href =\""+fileName+"_IncompletedList.html\">List</a></div></td>");
+    	    	createIncompletedList(fileName,linkName);
+        	    
+    	    }
+    	    else{
+    	    	out.write ("<th title = \"The completeness means the arithmetic average \">Completeness\r\n");
+    	    }
+    	    out.write ("<td class=\"tam\"> "+dmx.Mean(name) +"%\r\n");
+    		out.write ("</tr>\r\n");
+    		
+  		
+        	
+    		//System.out.println("step6");
+    	    out.write ("<tr>\r\n");
+    	    //out.write ("<th title=\" Minimum number of occurrence of a value\">Smallest Number\r\n");
+    	    //out.write ("<th><div style=\"float:left;\">Smallest Number</div><div style=\"float:right;\" onClick=\"alert('Minimum "+name +" usage in any record')\">What it this?</div>\r\n");
+    	    out.write ("<td><b><div style=\"float:left;\">Minimum "+name +" usage in any record</div></b><div style=\"float:right;\"> <a href=\"#\" onClick=\"helpWindow('Minimum','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
+    	    //out.write ("<td><b><div style=\"float:left;\">Minimun "+name +" usage in any record</div></b><div style=\"float:right;\"> onClick=\"helpWindow('Minimun','"+name+"')\">What's this?</div>\r\n");
+    	    out.write ("<td class=\"tam\"> "+dm.getMinRange(name) +"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step7");
+    	    out.write ("<tr>\r\n");
+    	    //out.write ("<th title=\" Maximum number of occurrence of a value\">Largest Number\r\n");
+    	    //out.write ("<th><div style=\"float:left;\">Largest Number</div><div style=\"float:right;\" onClick=\"alert('Maximum "+name +" usage in any record')\">What's this?</div>\r\n");
+    	    out.write ("<td><b><div style=\"float:left;\">Maximum "+name +" usage in any record</div></b><div style=\"float:right;\"> <a href=\"#\" onClick=\"helpWindow('Maximum','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
+    	    out.write ("<td class=\"tam\"> "+dm.getMaxRange(name) +"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step8");
+    	    out.write ("<tr>\r\n");
+    	    //out.write ("<th title=\"(Total times element used / No. of records containing element)\">Average\r\n");
+    	    //out.write ("<th><div style=\"float:left;\">Average</div><div style=\"float:right;\" onClick=\"alert('Average "+name +" usage/record')\">What's this?</div>\r\n");
+    	    out.write ("<td><b><div style=\"float:left;\">Average "+name +" usage/record</div></b><div style=\"float:right;\"> <a href=\"#\" onClick=\"helpWindow('Average','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
+    	    out.write ("<td class=\"tam\"> "+dm.Average(name) +"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step9");
+    	    out.write ("<tr>\r\n");
+    	    //out.write ("<th title=\"The most frequent occurrence value in a group of values \"> Mode\r\n");
+    	    //out.write ("<th><div style=\"float:left;\">Mode</div><div style=\"float:right;\" onClick=\"alert('Mode of "+ name +" usage/record')\">What's this?</div>\r\n");
+    	    out.write ("<td><b><div style=\"float:left;\">Mode of "+name +" usage/record</div></b><div style=\"float:right;\"><a href=\"#\" onClick=\"helpWindow('Mode','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
+    	    out.write ("<td class=\"tam\"> "+dm.getMode(name) +"\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//System.out.println("step10");
+    	    out.write ("<tr>\r\n");
+    	    //out.write ("<th>Mode Frequency\r\n");
+    	    //out.write ("<th><div style=\"float:left;\">Mode Frequency</div><div style=\"float:right;\" onClick=\"alert('Coverage of the mode of "+ name +" usage/record')\">What's this?</div>\r\n");
+    	    out.write ("<td><b><div style=\"float:left;\">Coverage of the mode of "+name +" usage/record</div></b><div style=\"float:right;\"><a href=\"#\" onClick=\"helpWindow('Mode Frequency','"+name+"')\" style=\"font-size:small;\">What's this?</a></div>\r\n");
+    	    out.write ("<td class=\"tam\">"+dm.ModeFrequency(name) +"%\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		
+    		
+    		out.write ("<tr>\r\n");
+    		out.write ("<td class=\"tam\"><a href =\""+fileName+"_Frequency-based.html\">"+"View Full Frequency Sorted list</a>" +
+    				  " <td class=\"tam\"><a href =\""+fileName+"_ASCII.html\">"+"View Full ASCII Sorted list</a></div></td>");
+    		out.write ("</tr>\r\n");
+    		
+    		HashMap suggestionMap = generateMetadataElementSortList(fileName,"ASCII",linkName);
+    		
+    		if(suggestionMap.size()>0){
+    			compareElement(fileName,collectionFolder,suggestionMap,linkName);
+    			out.write("<tr><td class=\"tam\"><a href =\""+fileName+"_Suggestion.html\">View<a><td>&nbsp;");
+    		}
+    		
+    		generateMetadataElementSortList(fileName,"Frequency-based",linkName);
+    		
+    		out.write ("</table><br>\r\n");
+    		
+    		
+    	    out.write ("<table border=\"1\" align=\"center\" width=1000>\r\n");
+    	    out.write ("<colgroup width=\"500\" span=\"2\">\r\n");
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>ASCII-Based\r\n");
+    	    out.write ("<th>First Five\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		
+    		
+        	String[] temp = dmx.getSortList(name,"ASCII");
+        	
+
+        	String[] temp2 = {"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
+        	int length = 0;
+        	//int counter = 0;
+        	//counter = temp.length;
+        	if(temp.length>=5){length=5;}
+        	else if(temp.length<5){length = temp.length;}
+                
+        	for(int i =0; i<length; i++){
+        	    temp2[i] = temp[i];
+        	}
+        	
+
+        	
+        	int x = temp2.length;
+        	for(int a = 0; a<x; a++){
+        		out.write ("<tr>\r\n");
+        		if(!temp2[a].equals("&nbsp;")){
+        			out.write ("<th>"+(a+1)+"\r\n");
+        		}
+        		else{
+        			out.write ("<th>&nbsp;\r\n");
+        		}
+        		if(temp2[a].startsWith("http")){
+        			if(temp2[a].length()>60){
+        				out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a].substring(0, 60)+"</a>");
+        			}
+        			else {
+        				out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a]+"</a>");
+        			}
+        		}
+        		else{
+        			char singleChar = temp2[a].charAt(0);
+        			if(temp2[a].length()>60){
+       			
+         				if(temp2[a].startsWith(" ") && ((int)singleChar!=65279)){
+        					temp2[a] = temp2[a].substring(1);
+        					out.write ("<td>"+spaceLeft+space+spaceRight+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#topFive\"> ... </a>\r\n");
+        				}
+         				
+         				else if (((int)singleChar==65279)){
+        					temp2[a] = temp2[a].substring(1);
+        					out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#topFive\"> ... </a>\r\n");
+        				}
+        				else{
+        					out.write ("<td>"+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#topFive\"> ... </a>\r\n");
+        				}
+        			}
+        			else {
+        				if(temp2[a].startsWith(" ") && ((int)singleChar!=65279)){
+        					temp2[a] = temp2[a].substring(1);
+        					out.write ("<td>"+spaceLeft+space+spaceRight+temp2[a]+"\r\n");
+        				}
+        				else if (((int)singleChar==65279)){
+        					temp2[a] = temp2[a].substring(1);
+        					out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a]+"\r\n");
+        				}
+        				else{
+        					out.write ("<td>"+temp2[a]+"\r\n");
+        				}
+        				//out.write ("<td>"+temp2[a]+"\r\n");
+        			}
+        		}
+        		out.write ("</tr>\r\n");
+        	}
+        	String[] temp3 ={"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
+        	length = 0;
+        	int start = temp.length;
+        	if(temp.length>=5){length= 5;}
+        	else if(temp.length<5){length = temp.length;}
+                
+        	for(int i = length; i>0; i--){
+        	    temp3[i-1] = temp[start-1];
+        	    start--;
+        	}
+    		out.write ("<tr>\r\n");
+    		out.write ("<th>......\r\n");
+    		out.write ("<th>Last Five\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		//counter = temp.length;
+    		start = temp.length;
+    		x = temp3.length;
+        	for(int a = 0; a<x; a++){
+        		out.write ("<tr>\r\n");
+
+        		if(!temp3[a].equals("&nbsp;")){
+        			out.write ("<th>"+(start-length+1+a));
+        		}
+        		else{
+        			out.write ("<th>&nbsp;");
+        		}
+        		if(temp3[a].startsWith("http")){
+        			if(temp3[a].length()>60){
+        				out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a].substring(0, 60)+"</a>");
+        			}
+        			else {
+        				//out.write ("<td>"+temp2[a]+"\r\n");
+        				out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a]+"</a>");
+        			}
+        		}
+        		else{
+        			char singleChar = temp3[a].charAt(0);
+        			if(temp3[a].length()>60){
+        				//out.write ("<td>"+temp3[a].substring(0, 60)+" ... \r\n");
+        				//System.out.println("7");
+        				//out.write ("<td>"+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... \r\n");
+        				//System.out.println("8");
+        				if(temp3[a].startsWith(" ") && (int)singleChar!=65279){
+        					temp3[a] = temp3[a].substring(1);
+        					out.write ("<td>"+spaceLeft+space+spaceRight+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... </a>\r\n");
+        				}
+        				
+        				else if((int)singleChar==65279){
+        					temp3[a] = temp3[a].substring(1);
+        					out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... </a>\r\n");
+        				
+        				}
+        				else{
+        					out.write ("<td>"+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_ASCII.html#lastFive\"> ... </a>\r\n");
+        				}
+        			}
+        			else{
+        				//out.write ("<td>"+temp3[a]+"\r\n");
+        				if(temp3[a].startsWith(" ") && (int)singleChar!=65279){
+        					temp3[a] = temp3[a].substring(1);
+        					out.write ("<td>"+spaceLeft+space+spaceRight+temp3[a]+"\r\n");
+        				}
+        				else if((int)singleChar==65279){
+        					out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a]+"\r\n");
+        				}
+        				else{
+        					out.write ("<td>"+temp3[a]+"\r\n");
+        				}
+        			}
+        			out.write ("</tr>\r\n");
+        		}
+        	}
+        	out.write ("</table><br>\r\n");
+        	//////////////////////////////////////////////////////////////////////////////////////////////////////
+        	//////////////////////////////////////////////////////////////////////////////////////////////////////
+    	    out.write ("<table border=\"1\" align=\"center\" width=1000>\r\n");
+    	    out.write ("<colgroup width=\"500\" span=\"2\">\r\n");
+    	    out.write ("<tr>\r\n");
+    	    out.write ("<th>Frequency-Based:\r\n");
+    	    out.write ("<th>First Five (Minimum ->Maximum)\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		HashMap xMap = dmx.getDistinctValueMap(name);
+        	temp = dmx.getSortList(name,"Frequency-based");
+        	temp2 = new String[] {"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
+        	length = 0;
+        
+        	if(temp.length>=5){length=5;}
+        	else if(temp.length<5){length = temp.length;}
+                
+        	for(int i =0; i<length; i++){
+        	    temp2[i] = temp[i];
+        	}
+        	
+        	ArrayList tempList = new ArrayList();
+        	for(int i =0; i<length; i++){
+        		if(((Integer)xMap.get(temp2[i])).intValue()==1){
+        			tempList.add(temp2[i]);
+        		}
+        	}
+        	//HashMap tempMap = dmx.getLinks(tempList, name);
+        	x = temp2.length;
+        	for(int a = 0; a<x; a++){
+        		out.write ("<tr>\r\n");
+        		//System.out.println("link map length"+tempMap.size());
+        		if(!temp2[a].equals("&nbsp;")){
+        			char singleChar = temp2[a].charAt(0);
+        			out.write ("<th>"+(a+1)+". (No. of occurrences: "+((Integer)xMap.get(temp2[a])).toString()+")\r\n");
+            		if(temp2[a].startsWith("http") && (int)singleChar != 65279){
+            			if(temp2[a].length()>60){
+            				out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a].substring(0, 60)+"</a>");
+            			}
+            			else {
+            				out.write ("<td><a href = \""+temp2[a]+"\">"+temp2[a]+"</a>");
+            			}
+            		}
+            		else if((int)singleChar == 65279){
+            			if(temp2[a].length()>60){
+            				out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a].substring(1, 60)+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... \r\n");
+             			}
+            			else{
+            				//out.write ("<td>"+temp2[a]+"\r\n");
+            				out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp2[a]+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... \r\n");
+                 			
+            			}
+            		}
+            		else{
+            			if(temp2[a].length()>60){
+            				out.write ("<td>"+temp2[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... \r\n");
+            			}
+            			else{
+            				out.write ("<td>"+temp2[a]+"\r\n");
+            			}
+            		}
+       		
+        		}
+        		else{
+        			//out.write ("<th>"+(a+1)+"\r\n");
+        			out.write ("<th>&nbsp;\r\n");
+        			out.write ("<td>\r\n");
+        		}
+        		
+
+        		out.write ("</tr>\r\n");
+        	}
+
+        	temp3 = new String[]{"&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;"};
+        	length = 0;
+        	start = temp.length;
+        	if(temp.length>=5){length= 5;}
+        	else if(temp.length<5){length = temp.length;}
+                
+        	for(int i = length; i>0; i--){
+        	    temp3[i-1] = temp[start-1];
+        	    start--;
+        	}
+
+    		out.write ("<tr>\r\n");
+    		out.write ("<th>......\r\n");
+    		out.write ("<th>Last Five (Maximum -> Minimum)\r\n");
+    		out.write ("</tr>\r\n");
+    		
+    		x = temp3.length;
+    		start = temp.length;
+        	for(int a = 0; a<x; a++){
+        		out.write ("<tr>\r\n");
+        		if(!temp3[a].equals("&nbsp;")){
+        			out.write ("<th>"+(start-length+1+a)+". (No. of occurrences: "+((Integer)xMap.get(temp3[a])).toString()+")\r\n");
+        			char singleChar = temp3[a].charAt(0);
+            		if(temp3[a].startsWith("http") && (int)singleChar!=65279){
+            			if(temp3[a].length()>60){
+            				out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a].substring(0, 60)+"</a>");            			
+            			}
+            			else {
+            				//out.write ("<td>"+temp2[a]+"\r\n");
+            				out.write ("<td><a href = \""+temp3[a]+"\">"+temp3[a]+"</a>");
+            			}
+            		}
+            		else if((int)singleChar==65279){
+            			if(temp3[a].length()>60){
+            				//System.out.println("15");
+            				out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a].substring(1, 60)+"<a href=\""+fileName+"_Frequency-based.html#lastFive\"> ... \r\n");
+            				//System.out.println("16");
+            				
+            			}
+            			else{
+            				//out.write ("<td>"+temp3[a]+"\r\n");
+            				out.write ("<td>"+spaceLeft+oddChar+spaceRight+temp3[a]+"<a href=\""+fileName+"_Frequency-based.html#topFive\"> ... \r\n");
+            			}
+            		}
+            		else{
+            			if(temp3[a].length()>60){
+            				//out.write ("<td>"+temp3[a].substring(0, 60)+" ... \r\n");
+            				//System.out.println("15");
+            				out.write ("<td>"+temp3[a].substring(0, 60)+"<a href=\""+fileName+"_Frequency-based.html#lastFive\"> ... \r\n");
+            				//System.out.println("16");
+            				
+            			}
+            			else{
+            				out.write ("<td>"+temp3[a]+"\r\n");
+            			}
+            		}
+            		
+        		}
+        		else{
+        			//out.write ("<th>"+(a+1)+". (No. of occurrences: 0)\r\n");
+        			//out.write ("<th>\r\n");
+        			//out.write ("<th>"+(a+1)+"\r\n");
+        			out.write ("<th>&nbsp;\r\n");
+        			out.write ("<th>\r\n");
+        		}
+        		
+
+        		//out.write ("<td>"+temp3[a]+"\r\n");
+        		out.write ("</tr>\r\n");
+        	}
+    		
+    		
+    	    out.write ("</table>\r\n");
+    	    
+    		//generateMetadataElementSortList(fileName,"ASCII",linkName);
+    		/*
+    		if(suggestionMap.size()>0){
+    			compareElement(fileName,collectionFolder,suggestionMap);
+    			out.write("<p><a href =\""+fileName+"\"_Suggestion.html>Link<a>");
+    		}
+    		*/
+    		//generateMetadataElementSortList(fileName,"Frequency-based",linkName);
+    		 //out.write ("<p>");
+    	    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    	    out.write ("<p> <a href=\" Overall.html \">Summary</a>");
+    	    out.write ("&raquo;");
+    	    
+    	  	if(linkName.equalsIgnoreCase("dublin")){
+    	  		out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+	    		//out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet1+"</h1>\r\n");
+	    	}
+	    	else if (linkName.equalsIgnoreCase("extracted")){
+	    		out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+	    		//out.write ("<h1 align=\"center\">Metadata Set Detail: "+metadataSet2+"</h1>\r\n");
+	    	}
+	    	else{
+	    		out.write ("<a href=\""+linkName+".html\">Metadata Detail ("+linkName+")</a>"); 	  
+	    	}
+    	    //out.write(str+"</p>");
+    	    out.write ("</body></html>\r\n");
+
+    	    //Close the output stream
+    	    out.close();
+    	}catch (Exception e){//Catch exception if any
+    		//System.out.println("detail");
+    	    System.err.println("Error: " + e.getMessage());
+    	}
+    	//System.out.println("detail ends");
+    	
+    }
+    
+    /*
+    private void generateMetadataElementSortList(String title, String sort, String metadataSetName){
+		//String str = sdf.format(cl.getTime());
+		//String collectionFolder = mds.getCollectionName();
+    	String fileName = title+"_"+sort;
+    	String collectionFolder = mds.getCollectionName();
+    	DataMaker dmx = new DataMaker(this.mds);
+    	
+    	//if(title.equals("dc.Identifier")){
+    		//return;
+    	//}
+    	
+    	try{
+	    FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
+	    BufferedWriter out = new BufferedWriter(fstream);
+    	
+    	out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+	    out.write ("<html>\r\n");
+	    out.write("<head>\r\n<title>Metadata Element Sort List</title>\r\n");
+	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+	    out.write("<style type=\"text/css\">\r\n");
+	    out.write("td{height:20; text-align:justify;}\r\n");
+	    out.write(".tam{height:20; text-align:center}\r\n");
+	    out.write("th{height:20; text-align:left;}\r\n");
+	    out.write("body{font-family: Arial;}\r\n");
+	    out.write("</style>\r\n");
+	    out.write("</head><body>\r\n");
+    	
+	    out.write("<p><a href=\" Overall.html \">Summary</a>");
+	    out.write("&raquo;");
+	    ////////////////////////////////////////////////////////////////////////////////////
+	  	if(metadataSetName.equalsIgnoreCase("dublin")){
+	  		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+    	}
+    	else if (metadataSetName.equalsIgnoreCase("extracted")){
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+    	}
+    	else{
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+    	}
+	  	out.write("&raquo;");
+	  	out.write("<a href=\""+title+".html\">"+title+"</a></p>"); 
+	  	
+	  	SearchLink sl = new SearchLink();
+       	String[] list = dmx.getSortList(title, sort);
+       	System.out.println(list.length+" length" + title);
+    	if(list.length>=1){
+    		
+        	out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
+        	out.write("<colgroup width=\"400\" span=\"2\">\r\n");
+        	out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");      	
+        	out.write ("<th class=\"tam\">"+ sort+"\r\n");
+        	out.write ("<th class=\"tam\">Element Values\r\n");
+        	
+    		out.write ("<a name='topFive'>\r\n");
+    		
+    		if(sort.equals("ASCII")){
+    			
+    			//System.out.println("ASCII STARTS");
+    			int counter = 0;
+
+    			for(int i = 0; i<list.length; i++){
+    				//System.out.println(i);
+    				if(list.length<=5 && i==0){
+    					out.write ("<a name='lastFive'>\r\n");
+    				}
+    				else if((list.length>5) && (list.length-5==i)){
+    					out.write ("<a name='lastFive'>\r\n");
+    				}
+    				out.write("<tr>\r\n");
+    				
+    				if(list[i].length()>=200){
+    					//out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"... \r\n");
+       					if(list[i].startsWith("http://")){
+    						//out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    						out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    					}
+    					else{
+    						///////////////////////////////////// adding links
+    						//System.out.println("MDE: "+title+" Text: "+ list[i]+ " Collection: "+ collectionFolder);
+    						ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder);
+    						//System.out.println(alist.get(0)+"?????????????????????????????????/");
+    						//////////////////////////////////////
+    						
+    						if(list[i].startsWith(" ")){
+    							list[i] = list[i].substring(1);
+    							////////////////////////////////////////////////////////////////////////////////////////////////////////
+    							if(alist.size()>=1){
+    								out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"..." +
+    										"<a href=\""+(String)alist.get(0)+"\"> Link</a>\r\n");
+    							}
+    							else{
+    								out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"... \r\n");
+    							}
+    							/////////////////////////////////////////////////////////////////////////////////////////////////////////
+    							
+    						}
+    						else{
+    							////////////////////////////////////////////////////////////////////////////////////////////////////////
+    							if(alist.size()>=1){
+    								out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"..." +
+    										"<a href=\""+(String)alist.get(0)+"\"> Link</a>\r\n");
+    							}
+    							else{
+    								out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"... \r\n");
+    							}
+    							/////////////////////////////////////////////////////////////////////////////////////////////////////////
+    							
+    						}
+    					}
+    				}
+    				else{
+    					//out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
+    					if(list[i].startsWith("http://")){
+    						out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    					}
+    					else{
+    						
+    						///////////////////////////////////// adding links
+    						//System.out.println("MDE: "+title+" Text: "+ list[i]+ " Collection: "+ collectionFolder);
+    						ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder);
+    						//System.out.println(alist.get(0)+"?????????????????????????????????/");
+    						//////////////////////////////////////
+    						
+    						if(list[i].startsWith(" ")){
+    							list[i] = list[i].substring(1);
+    							//out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
+    							
+    							////////////////////////////////////////////////////////////////////////////////////////////////////////
+    							if(alist.size()>=1){
+    								out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"..." +
+    										"<a href=\""+(String)alist.get(0)+"\"> Link </a>\r\n");
+    							}
+    							else{
+    								out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"... \r\n");
+    							}
+    							/////////////////////////////////////////////////////////////////////////////////////////////////////////
+    							
+    						}
+    						else{
+    							if(alist.size()>=1){
+    								out.write("<td>"+(counter+1)+"<td>"+list[i]+"<a href=\""+alist.get(0)+"\"> Link </a>\r\n");
+    							}
+    							else{
+    								out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
+    							}
+    						}
+    					}
+    				}
+    				counter++;
+    			}
+    		}
+    		else{
+    			HashMap xMap = dmx.getDistinctValueMap(title);
+    			int counter = 0;
+    			//System.out.println("frequency STARTS");
+    			for(int i = 0; i<list.length; i++){
+    				if(list.length<=5 && i==0){
+    					out.write ("<a name='lastFive'>\r\n");
+    				}
+    				else if((list.length>5) && (list.length-5==i)){
+    					out.write ("<a name='lastFive'>\r\n");
+    				}
+    				out.write("<tr>\r\n");
+    				out.write("<th>"+(counter+1)+". (No. of occurrences: "+((Integer)xMap.get(list[i])).toString()+")\r\n");
+    				
+    				if(list[i].length()>=200){
+    					
+    					//System.out.println(i + " <- 1f -> " +list[i]);
+    					//out.write("<td>"+list[i].substring(0,200)+"\r\n");
+    					if(list[i].startsWith("http://")){
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    					}
+    					else{
+    						if(list[i].startsWith(" ")){
+    							list[i]=list[i].substring(1);
+    							out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"\r\n");
+    						}
+    						else{
+    							out.write("<td>"+list[i].substring(0,200)+"\r\n");
+    						}
+    					}
+    				}
+    				else{
+    					//System.out.println(i + " <- 2f -> " +list[i]);
+    					//out.write("<td>"+list[i]+"\r\n");
+    					if(list[i].startsWith("http://")){
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    					}
+    					else{
+    						if(list[i].startsWith(" ")){
+    							list[i]=list[i].substring(1);
+    							//out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"\r\n");
+    							out.write("<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
+    						}
+    						else{
+    							out.write("<td>"+list[i]+"\r\n");
+    						}
+    					}
+    				}
+    				counter++;
+    			}   		  	
+    		}
+    		out.write("</table>\r\n");
+    	}
+    	else{
+    		out.write("<p>Sorry! The list is empty</p>");
+    	}
+    	out.write("<tr>\r\n");
+    	
+    	
+	    out.write("<p><a href=\" Overall.html \">Summary</a>");
+	    out.write("&raquo;");
+	    ////////////////////////////////////////////////////////////////////////////////////
+	  	if(metadataSetName.equalsIgnoreCase("dublin")){
+	  		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+    	}
+    	else if (metadataSetName.equalsIgnoreCase("extracted")){
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+    	}
+    	else{
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+    	}
+	  	out.write("&raquo;");
+	  	out.write("<a href=\""+title+".html\">"+title+"</a></p>"); 
+    	out.write("</body></html>\r\n");
+    	out.close();
+      	}catch(Exception e){
+      		e.printStackTrace();
+    		//sSystem.err.println("Error: " + e.printStackTrace());
+    	}
+    }
+    
+   */
+    private void setupMetadataLink(String fileName){
+    	
+    	try{
+    		DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+    		DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+    		Document doc = docBuilder.newDocument();
+    		doc = docBuilder.parse (new File("/research/cc108/greenstone3/web/mat/script/"+fileName+".xml"));
+    		Element rootNode = doc.getDocumentElement();
+    		
+    		NodeList listOfName = rootNode.getElementsByTagName("metadataElement");
+    		 url = new HashMap();
+    		for(int i = 0; i<listOfName.getLength(); i++){
+    			  Node NameNode = listOfName.item(i);
+    			  Element docElement = (Element)NameNode;
+    			  NodeList valueList = docElement.getElementsByTagName("URL");
+    			  Node urlParentNode = valueList.item(0);
+    			  String urlText = urlParentNode.getChildNodes().item(0).getNodeValue();
+    			  
+    			  valueList = docElement.getElementsByTagName("name");
+    			  Node urlNameParentNode = valueList.item(0);
+    			  String urlNameText = urlNameParentNode.getChildNodes().item(0).getNodeValue();
+    			  
+    			  url.put(urlNameText, urlText);
+    			  //System.out.println(urlText+" "+urlNameText);
+    			  
+    		}
+    		
+    		
+    	}catch(Exception e){
+    		//e.printStackTrace(printWriter);
+    		System.out.print(e.toString());
+    	}
+    }
+    private HashMap generateMetadataElementSortList(String title, String sort, String metadataSetName){
+    
+        	String fileName = title+"_"+sort;
+        	String collectionFolder = mds.getCollectionName();
+        	String IDENTIFIER = "dc.Identifier";
+        	SearchLink sl = new SearchLink();
+        	HashMap suggestionMap = new HashMap();
+    		boolean status = false;
+        	try{
+        	HashMap valueMap = sl.createValueMap(title,collectionFolder);
+        	HashMap linkMap = sl.createLinkMap("dc.Identifier",collectionFolder);
+        	HashMap internalIDMap = dm.getInternalIdentifier(title);	
+    	    FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+".html");
+    	    BufferedWriter out = new BufferedWriter(fstream);
+
+    	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+    	    out.write ("<html>\r\n");
+    	    out.write("<head>\r\n<title>Metadata Element Sort List</title>\r\n");
+    	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+    	    //out.write("<link rel=\"stylesheet\" href=\"../script/doby2.css\" type=\"text/css\"/>\r\n");
+    	    out.write("<script type=\"text/javascript\" src=\"../script/getInfomation.js\"></script>\r\n");   	    
+    	    out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js\"></script>\r\n");
+    	    out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/event/event-min.js\"></script>\r\n");
+    	    out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js\"></script>\r\n");
+    	    out.write("<style type=\"text/css\">\r\n");
+    	    out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
+    	    out.write(".tam{height:20; text-align:center}\r\n");
+    	    out.write("th{height:20; text-align:center;}\r\n");
+    	    out.write("body{font-family: Arial;}\r\n");
+    	    out.write("</style>\r\n");
+    	    out.write("</head><body id=\""+collectionFolder+"\">\r\n");
+        	
+    	    out.write("<td><div style=\"float:left;\"><a href=\" Overall.html \">Summary</a>");
+    	    out.write("&raquo;");
+    	    ////////////////////////////////////////////////////////////////////////////////////
+    	    if(metadataSetName.equalsIgnoreCase("dublin")){
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+    	    }/*
+    	    else if (metadataSetName.equalsIgnoreCase("extracted")){
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+    	    }*/
+    	    else{
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+    	    }
+    	    out.write("&raquo;");
+    	    out.write("<a href=\""+title+".html\">"+title+"</a></div>"); 
+    	  	
+    	  	
+    	    // out.write ("<td> <div style=\"float:left;\"> <a href=\" Overall.html \">Summary</a></div>");
+    	    out.write("<div style=\"float:right;\"><a href=\"http://chnm.gmu.edu/tools/surveys/4386/\">Please send feedback about the Mat tool</a></div></td><br>");
+     	  
+    	  	//kljkl
+    	    String[] list = dm.getSortList(title, sort);
+    	    //String Link = "Link";
+    	    //int MaxLinks = 2;
+          
+           	
+    	    if(list.length>=1){
+        		
+        		
+        	if(sort.equals("ASCII")){
+        			
+        		out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
+                out.write("<h2 align=\"center\">"+ title+"</h2>\r\n");      	
+                out.write("<th class=\"tam\">ASCII Sort\r\n");
+                out.write("<th class=\"tam\">Element Values\r\n");
+                out.write("<th class=\"tam\">Source Documents\r\n"); 
+                out.write("<th class=\"tam\">InternalLink\r\n"); 
+                	
+                out.write ("<a name='topFive'>\r\n");
+            		
+                int counter = 0;
+
+                for(int i = 0; i<list.length; i++){
+                	if(list.length<=5 && i==0){
+                		out.write ("<a name='lastFive'>\r\n");
+                	}
+                	else if((list.length>5) && (list.length-5==i)){
+                		out.write ("<a name='lastFive'>\r\n");
+                	}
+                	
+                	
+                	InternalLink il= (InternalLink)internalIDMap.get(list[i]);
+                	ArrayList alist2 = il.retrieveList();
+                	String id = (String)alist2.get(0);
+                	id = id.substring(4);
+                	out.write("<tr id=\""+id+"\" >\r\n");
+    		  		
+    		  		//out.write("<tr>\r\n");
+
+        				
+                	if(list[i].length()>=201){
+                		if(list[i].startsWith("http://")){
+   
+                			if(title.equals("dc.Identifier")){
+                				if(list[i].length()>=100){
+                					out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+                				}
+                				else{
+                					out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+                				}
+                				out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    						//out.write("<td id=\""+internalIDMap.get(list[i])+"\">");
+                			}
+    				else{
+    				
+    					ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
+    					System.out.println("break");
+    					if(list[i].length()>=100){
+    						
+    						//out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    						String url = (String)alist.get(0);
+    						if(alist.size()==1){
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    							if(url.startsWith("http://")){
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    							}else{
+    								out.write("<td>Source\r\n");
+    							}
+    							//suggestionMap.put(list[i], url);
+    						}
+    						else if(alist.size()>1){
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    							//out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");	
+    							if(url.startsWith("http://")){
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    							}else{
+    								out.write("<td>Source\r\n");
+    							}
+    							//suggestionMap.put(list[i], url);
+    						}
+    						else{
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							out.write("<td>No Source Available\r\n");	
+    						}
+    						suggestionMap.put(list[i], url);
+    						//out.write("<td id=\""+internalIDMap.get(list[i])+"\">");
+    					}
+    					else{
+    						//out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    						String url = (String)alist.get(0);
+    						if(alist.size()==1){
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							//out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    							if(url.startsWith("http://")){
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    							}else{
+    								out.write("<td>Source\r\n");
+    							}
+    						}
+    						else if(alist.size()>1){
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							//out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");	
+    							if(url.startsWith("http://")){
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    							}else{
+    								out.write("<td>Source\r\n");
+    							}
+    						}
+    						else{
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							out.write("<td>No Source Available\r\n");	
+    						}
+    						suggestionMap.put(list[i], url);
+    					}
+    				}
+    			    //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0, 200)+"...</a>");
+    				
+    			   
+    			}
+    			else{
+    			    ///////////////////////////////////// adding links have not change the empty link form here
+    			    ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
+    			    //////////////////////////////////////
+        						
+    			    if(list[i].startsWith(" ")){
+        			String elements = list[i];
+    				list[i] = list[i].substring(1);
+
+				    //out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"\r\n");
+
+    				
+    				if(alist.size()==1){
+    				    out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>"+
+    					      "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    	   						suggestionMap.put(elements, (String)alist.get(0));
+    				}
+    				else if(alist.size()>1){
+    				    out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>"+
+    						      "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    	   						suggestionMap.put(elements, (String)alist.get(0));
+    				}
+    				else{
+    				    out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i].substring(0, 200)+"...<td>No Source Available \r\n");
+    	   					suggestionMap.put(elements, "No Source Available");
+    				}
+ 
+    			    }
+    			    else{
+    			    	//out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"...<td>\r\n");
+        				
+    				if(alist.size()==1){
+    				    out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"...<td>" +
+    					      "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+   						suggestionMap.put(list[i], (String)alist.get(0));
+    				}
+    				else if(alist.size()>1){
+    				    out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"...<td>" +
+    						      "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+   						suggestionMap.put(list[i], (String)alist.get(0));
+    				}	
+    				else{
+    				    out.write("<td>"+(counter+1)+"<td>"+list[i].substring(0, 200)+"... <td>No Source Available\r\n");
+   						suggestionMap.put(list[i],"No Source Available");
+    				}
+    				
+    			    }
+    			}
+        			
+    		    }
+    		    else{
+        		/*	   					
+    			if(list[i].startsWith("http://")){
+    			    //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    				   //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">1</a>");
+    				   
+    					if(list[i].length()>=100){
+    						   out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    					}
+    					else{
+    						   out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    					}
+    					
+    			    out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    			}*/
+    		    	
+    		    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    				if(list[i].startsWith("http://")){
+    				    //out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    					if(title.equals("dc.Identifier")){
+    						if(list[i].length()>=100){
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    							//out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    						}
+    						else{
+    							out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    						}
+    							out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    					}
+    					else{
+    						ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
+    						if(list[i].length()>=100){
+    							//out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>\r\n");
+    							
+    							if(alist.size()==1){
+    								out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    								suggestionMap.put(list[i], (String)alist.get(0));
+    							}
+    							else if(alist.size()>1){
+    								out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"...</a>");
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");	
+    								suggestionMap.put(list[i], (String)alist.get(0));
+    							}
+    							else{
+    								out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    								out.write("<td>No Source Available\r\n");	
+    								suggestionMap.put(list[i],"No Source Available");
+    							}
+    						}
+    						else{
+    							//out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>\r\n");
+    							//out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							
+    							if(alist.size()==1){
+    								out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    								suggestionMap.put(list[i], (String)alist.get(0));
+    							}
+    							else if(alist.size()>1){
+    								out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    								out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    								suggestionMap.put(list[i], (String)alist.get(0));
+    							}
+    							else{
+    								out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    								out.write("<td>No Source Available\r\n");	
+    								suggestionMap.put(list[i],"No Source Available");
+    							}
+    							
+    						}
+    					}
+    				    //out.write("<td>"+(counter+1)+"<td><a href=\""+list[i]+"\">"+list[i].substring(0, 200)+"...</a>");
+    					
+    				   
+    				}
+    		    
+    				///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+        					
+    			else{
+    			    ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
+    			    
+    			    if(list[i].startsWith(" ")){
+    			    	String elements = list[i];
+    				list[i] = list[i].substring(1);
+    				 //out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
+        				
+    				if(alist.size()==1){
+    				    out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+
+    					      "<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    				    suggestionMap.put(elements,(String)alist.get(0));
+    				}
+    				else if(alist.size()>1){
+    				    out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+
+    					      "<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    				    suggestionMap.put(elements,(String)alist.get(0));
+    				}  				
+    				else{
+    				    out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"<td>No Source Available\r\n");
+    				    suggestionMap.put(elements,"No Source Available");
+    				}
+    				
+    				//out.write("<td>"+(counter+1)+"<td>"+spaceLeft+space+spaceRight+list[i]+"\r\n");
+    			    }
+    			    else{
+    			        //out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
+    			    	
+    				if(alist.size()==1){
+    				    out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td><a href=\""+alist.get(0)+"\">Source</a>\r\n");
+    				    suggestionMap.put(list[i],(String)alist.get(0));
+    				}
+    				else if(alist.size()>1){
+    				    out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td><a href=\""+alist.get(0)+"\">Source</a>...\r\n");
+    				    suggestionMap.put(list[i],(String)alist.get(0));
+    				}
+    				else{
+    				    out.write("<td>"+(counter+1)+"<td>"+list[i]+"<td>No Source Available\r\n");
+    				    suggestionMap.put(list[i],"No Source Available");
+    				}
+    				
+    				//out.write("<td>"+(counter+1)+"<td>"+list[i]+"\r\n");
+    			    }
+    			}
+    		    }
+    		    counter++;
+    		    out.write("<td onclick=\"GD(this)\">View");
+    		}
+                /////////////////////// insert 
+            	if(suggestionMap.size()>1 && !title.equals("dc.Identifier")){
+            		//return suggestionMap;
+            		//compareElement(title,collectionFolder,suggestionMap);
+            		status = true;
+            	}
+
+                ////////////////////////
+        		}
+        		else{
+        			
+        			
+                	out.write("<table border=\"1\" align=\"center\" width=\"800\">\r\n");
+                	out.write ("<h2 align=\"center\">"+ title+"</h2>\r\n");
+                	out.write ("<th class=\"tam\">&nbsp;\r\n");
+                	out.write ("<th class=\"tam\">Frequency\r\n");
+                	out.write ("<th class=\"tam\">Element Values\r\n");    
+                	out.write ("<th class=\"tam\">Source Documents\r\n");   
+                	out.write ("<th class=\"tam\">Internal Link\r\n"); 
+    		out.write ("<a name='topFive'>\r\n");
+            		
+    		HashMap xMap = dm.getDistinctValueMap(title);
+    		int counter = 0;
+    		for(int i = 0; i<list.length; i++){
+    		    if(list.length<=5 && i==0){
+    			out.write ("<a name='lastFive'>\r\n");
+    		    }
+    		    else if((list.length>5) && (list.length-5==i)){
+    			out.write ("<a name='lastFive'>\r\n");
+    		    }
+    		    
+    	    	InternalLink il= (InternalLink)internalIDMap.get(list[i]);
+            	ArrayList alist2 = il.retrieveList();
+            	String id = (String)alist2.get(0);
+            	id = id.substring(4);
+            	out.write("<tr id=\""+id+"\" >\r\n");
+            	
+    		    /*
+    		    InternalLink il= (InternalLink)internalIDMap.get(list[i]);
+    		    ArrayList alist2 = il.retrieveList();
+    		    String id = (String)alist2.get(0);
+    		    id = id.substring(4);
+    		    
+    		    out.write("<tr id=\""+id+"\" >\r\n");
+    		    */
+    		    out.write("<tr>\r\n");
+    		    out.write("<td>"+(counter+1)+"<th> "+((Integer)xMap.get(list[i])).toString()+"\r\n");
+        				
+    		    if(list[i].length()>=201){
+    		    	
+    			if(list[i].startsWith("http://")){
+    			    //out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,200)+"...</a>");
+    				if(title.equals("dc.Identifier")){
+    					if(list[i].length()>=100){
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    					}
+    					else{
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    					}
+    					
+    				    out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    				}
+    				else{
+    					ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
+    					if(list[i].length()>=100){
+    						if(alist.size()==1){
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							out.write("<td><a href=\""+alist.get(0)+"\">Source</a>\r\n");
+    						}
+    						else if (alist.size()>1){
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							out.write("<td><a href=\""+alist.get(0)+"\">Source</a>...\r\n");
+    						}
+    						else{
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							//out.write("<td><a href=\""+alist.get(0)+"\">Source</a>...\r\n");
+    							out.write("<td>No Source Available\r\n");	
+    						}
+    					
+    					}
+    					else{
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    					}
+    				
+    			    //out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    				}
+    			}
+    			
+    			
+    			
+    			
+    			else{
+    			    ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
+        						
+    			    if(list[i].startsWith(" ")){
+    				list[i]=list[i].substring(1);
+    					if(alist.size()==1){
+    						out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>"+
+    						"<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    					}
+    					else if(alist.size()>1){
+    						out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>"+
+    					      "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    					}
+    					else{
+    						out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"...<td>No Source Available\r\n");
+    					}
+    			    }
+    			    else{
+    			    	
+    			    	if(alist.size()==1){
+    			    		out.write("<td>"+list[i].substring(0,200)+"...<td>" +
+    					      "<a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    			    	}
+    			    	else if(alist.size()>1){
+    			    		out.write("<td>"+list[i].substring(0,200)+"...<td>"+
+    					      "<a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    			    	}
+    			    	else{
+    			    		out.write("<td>"+list[i].substring(0,200)+"...<td>No Source Available\r\n");
+    			    	}
+    			    }
+    			}
+    		    }
+    		    else{
+    			if(list[i].startsWith("http://")){
+    			    //out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    				//out.write("<td><a href=\""+list[i]+"\">1</a>");
+    				if(title.equals("dc.Identifier")){
+    					if(list[i].length()>=100){
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    					}
+    					else{
+    						out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    					}
+    				    out.write("<td><a href=\""+list[i]+"\">Source</a>\r\n");
+    				}
+    				else{
+    					ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],"dc.Identifier", collectionFolder,valueMap,linkMap);
+    					if(list[i].length()>=100){
+    						if(alist.size()==1){
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    						}
+    						else if(alist.size()>1){
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    						}
+    						else{
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i].substring(0,100)+"</a>");
+    							out.write("<td>No Source Available\r\n");
+    						}
+    					}
+    					else{
+    						if(alist.size()==1){
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    						}
+    						else if(alist.size()>1){
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							out.write("<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    						}
+    						else{
+    							out.write("<td><a href=\""+list[i]+"\">"+list[i]+"</a>");
+    							out.write("<td>No Source Available\r\n");
+    						}
+    					}
+    					
+    				}
+    				
+    			}
+    			else{
+    			    
+    			    ArrayList alist= sl.CreateIndentifierLinkPage(title, list[i],IDENTIFIER, collectionFolder,valueMap,linkMap);
+        						
+    			    if(list[i].startsWith(" ")){
+    				list[i]=list[i].substring(1);
+    				//out.write("<td>"+spaceLeft+space+spaceRight+list[i].substring(0,200)+"\r\n");
+    				if(alist.size()==1){
+    				    out.write("<td>"+spaceLeft+space+spaceRight+list[i]+
+    					      "<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    				}
+    				else if(alist.size()>1){
+    				    out.write("<td>"+spaceLeft+space+spaceRight+list[i]+
+    					      "<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    				}
+    				else{
+    				    out.write("<td>"+spaceLeft+space+spaceRight+list[i]+"<td>No Source Available\r\n");
+    				}
+    			    }
+    			    else{
+    				if(alist.size()==1){
+    				    out.write("<td>"+list[i]+"<td><a href=\""+(String)alist.get(0)+"\">Source</a>\r\n");
+    				}
+    				else if(alist.size()>1){
+    				    out.write("<td>"+list[i]+"<td><a href=\""+(String)alist.get(0)+"\">Source</a>...\r\n");
+    				}
+    				else{
+    				    out.write("<td>"+list[i]+"<td>No Source Available\r\n");
+    				}
+    			    }
+    			}
+    		    }
+    		    counter++;
+
+    		    out.write("<td onclick=\"GD(this)\">View");
+    		    //out.write("<td id=\""+internalIDMap.get(list[i])+"\">Click");
+    		}   		  	
+    		
+        		}
+        		out.write("</table>\r\n");
+    	    }
+    	    else{
+        		out.write("<p>Sorry! The list is empty</p>");
+        	}
+    	    out.write("<tr>\r\n");
+        	
+        	
+    	    out.write("<p><a href=\" Overall.html \">Summary</a>");
+    	    out.write("&raquo;");
+    	    ////////////////////////////////////////////////////////////////////////////////////
+    	    if(metadataSetName.equalsIgnoreCase("dublin")){
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+    	    }
+    	    else if (metadataSetName.equalsIgnoreCase("extracted")){
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+    	    }
+    	    else{
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+    	    }
+    	    out.write("&raquo;");
+    	    out.write("<a href=\""+title+".html\">"+title+"</a></p>"); 
+    	    out.write("</body></html>\r\n");
+    	    out.close();
+    	    fstream.close();
+          	}catch(Exception e){
+        		System.err.println("Error: " + e.getMessage());
+    	    //e.printStackTrace(outx);
+        	}
+        	
+    	//printWriter.write("<!-- generating all possible page-->");
+    	//printWriter.flush();
+          	//return new HashMap();
+          	if(status){
+          		return suggestionMap;
+          	}
+          	else{
+          		return new HashMap();
+          	}
+        }
+        
+    private void createIncompletedList(String fileName, String metadataSetName){
+    	//System.out.println("break1");
+    	HashMap hp = dm.getIdentifierLink("dc.Identifier");
+    	String[] ids = dm.getDocumentIDList(fileName);
+    	System.out.println("Length: "+ids.length+" "+fileName+ " "+hp.size());
+    	for(int i = 0; i<ids.length; i++){
+    		hp.remove(ids[i]);
+    	}
+      	String collectionFolder = mds.getCollectionName();
+    	System.out.println(hp.size());
+    	try{	
+	    FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+"_IncompletedList.html");
+	    BufferedWriter out = new BufferedWriter(fstream);
+	    
+	    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+	    out.write ("<html>\r\n");
+	    out.write("<head>\r\n<title>Incompleted Document List</title>\r\n");
+	    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+	    out.write("<style type=\"text/css\">\r\n");
+	    out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
+	    out.write(".tam{height:20; text-align:center}\r\n");
+	    out.write("th{height:20; text-align:center;}\r\n");
+	    out.write("body{font-family: Arial;}\r\n");
+	    out.write("</style>\r\n");
+	    out.write("</head><body>\r\n");
+	    
+	    out.write("<p><a href=\" Overall.html \">Summary</a>");
+	    out.write("&raquo;");
+	    if(metadataSetName.equalsIgnoreCase("dublin")){
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+    	}
+    	else if (metadataSetName.equalsIgnoreCase("extracted")){
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+    	}
+    	else{
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+    	}
+    	out.write("&raquo;");
+	    out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
+	    
+	    //out.write("<h3 align=center>"+fileName+"</h3>");
+	    out.write("<h3 align=center>"+fileName+" does not appear in the following documents</h3>");
+	    int counter = 0;
+	    Set s = hp.keySet();
+	    Iterator i = s.iterator();
+	    out.write("<table border=1 align=center><tr><th>Document ID<th>Source Link\r\n");
+	    while(i.hasNext()){
+	    	counter++;
+	    	String keys = (String)i.next();
+	    	InternalLink il = (InternalLink) hp.get(keys);
+	    	ArrayList alist = il.retrieveList();
+	    	String url = (String)alist.get(0);
+	    	out.write("<tr><td>"+counter+"<td><a href=\""+url+"\">"+url+"</a>\r\n");
+	    }
+	    out.write("</table></body></html>\r\n");
+	    
+	    
+	    out.write("<p><a href=\" Overall.html \">Summary</a>");
+	    out.write("&raquo;");
+	    if(metadataSetName.equalsIgnoreCase("dublin")){
+    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+    	}
+    	else if (metadataSetName.equalsIgnoreCase("extracted")){
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+    	}
+    	else{
+        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+    	}
+    	out.write("&raquo;");
+	    out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
+	    
+	    out.close();
+	    fstream.close();
+    	}catch(IOException ex){ex.printStackTrace();}
+    	
+    	
+    }
+        
+    
+	private void generateHTML(HashMap distanceMap, String fileName,String metadataSetName){
+		
+		String collectionFolder = mds.getCollectionName();
+		
+		try{	
+		    FileWriter fstream = new FileWriter(collectionFolder+"/"+fileName+"_Suggestion.html");
+		    BufferedWriter out = new BufferedWriter(fstream);
+		    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
+		    out.write ("<html>\r\n");
+		    out.write("<head>\r\n<title>Suggestion list</title>\r\n");
+		    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+		    out.write("<style type=\"text/css\">\r\n");
+		    out.write("td{height:20; text-align:left;padding-left:5px;}\r\n");
+		    out.write(".tam{height:20; text-align:center}\r\n");
+		    out.write("th{height:20; text-align:left;}\r\n");
+		    out.write("body{font-family: Arial;}\r\n");
+		    out.write("</style>\r\n");
+		    out.write("</head><body>\r\n");
+		    out.write("<p><a href=\" Overall.html \">Summary</a>");
+		    out.write("&raquo;");
+		    if(metadataSetName.equalsIgnoreCase("dublin")){
+	    		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet1+")</a>"); 
+	    	}
+	    	else if (metadataSetName.equalsIgnoreCase("extracted")){
+	        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSet2+")</a>"); 
+	    	}
+	    	else{
+	        		out.write ("<a href=\""+metadataSetName+".html\">Metadata Detail ("+metadataSetName+")</a>"); 	  
+	    	}
+	    	out.write("&raquo;");
+		    out.write("<a href=\""+fileName+".html \">"+fileName+"</a>");
+		    
+		    out.write("<table border=1 align=center>\r\n");
+		    //out.write("<tr><td>&nbsp;<td>&nbsp;\r\n");
+			Set s = distanceMap.keySet();
+			Iterator i = s.iterator();
+			while(i.hasNext()){
+				String keyword = (String)i.next();
+				InternalLink il = (InternalLink)distanceMap.get(keyword);
+				//ArrayList alist = il.retrieveList();
+				ArrayList alist = il.retrieveNodeList();
+			    //out.write("<tr><td>&nbsp;<td>&nbsp;\r\n");
+				//System.out.println("here");
+		
+			    //out.write("<tr><th>"+keyword+"\r\n");
+				out.write("<tr><th>&nbsp;<th>\r\n");
+				for(int a = 0; a<alist.size(); a++){
+					InternalLink il2 = new InternalLink();
+					il2 = (InternalLink)alist.get(a);
+					String url = (String)il2.retrieveList().get(0);
+					out.write("<tr><td>"+il2.getValue()+"<td><a href=\""+url+"\">"+url+"</a>");
+					//out.write("<tr><td>"+(String)alist.get(a));
+				}
+			    out.write("</tr>");
+				//System.out.println("\n\n");
+			}
+		    out.write("</table></body></html>\r\n");
+		    out.close();
+		    fstream.close();
+		}catch(IOException ex){ex.printStackTrace();}
+
+		//distanceMap.clear();
+		//System.gc();
+	}
+	
+	
+	public void compareElement(String fileName,String collectionFolder,HashMap suggestionMap, String metadataSetName){
+
+		//EditDistance ed = new EditDistance();
+		//SearchLink sl = new SearchLink();
+
+		System.out.println("Starting test "+fileName);
+	    long time = System.currentTimeMillis();
+		//List list = Arrays.asList(args);
+	    Set kset = suggestionMap.keySet();
+		ArrayList arrayList = new ArrayList();
+		Iterator is = kset.iterator();
+		while(is.hasNext()){
+			arrayList.add((String)is.next());
+		}
+		HashMap distanceMap = new HashMap();
+	
+		int totalLength = 0;
+
+		int arrayListLength = arrayList.size();
+		
+		System.out.println("Length: "+arrayListLength);
+		double distance ;
+		try{
+		for(int i = 0; i<arrayListLength; i++){
+			String keyword = (String)arrayList.get(i);
+			//ArrayList alistkw1 = sl.CreateIndentifierLinkPage(fileName, keyword,"dc.Identifier", collectionFolder,valueMap,linkMap);
+			int spaceCounterFront1 = 0;
+			int spaceCounterEnd1 = 0;
+			String keywordClone = keyword;
+			String _keywordClone = keyword;
+			String bkKeyWord = keyword;
+			//System.out.println("before parsing kw1");
+			keywordClone = removeUnusedCharacter(keywordClone);
+			//System.out.println("after parsing kw1");
+			//System.out.println("before removing space from kw1");
+			while(true){
+				if(_keywordClone.length()>1){
+				if(_keywordClone.charAt(0)==' '){
+					_keywordClone = _keywordClone.substring(1);
+					spaceCounterFront1++;
+				}
+				else{
+					if(_keywordClone.charAt(_keywordClone.length()-1)==' '){
+						_keywordClone = _keywordClone.substring(0,_keywordClone.length()-1);
+						spaceCounterEnd1++;
+					}
+					else{
+						break;
+					}
+				}
+				}
+				else{
+					break;
+				}
+			}
+			//System.out.println("after removing space from kw1");
+			/*
+			for(int a = 0; a<spaceCounterFront; a++){
+				keywordClone = spaceLeft+space+spaceRight+keywordClone;
+			}
+			for(int a = 0; a<spaceCounterFront; a++){
+				keywordClone = keywordClone+spaceLeft+space+spaceRight;
+			}
+			*/
+			//System.out.println("after5");
+			int keywordLength = keywordClone.length();
+			totalLength = totalLength + keywordLength;
+			for(int j = i+1; j<arrayListLength; j++){
+				String keyword2 = (String)arrayList.get(j);
+				//ArrayList alistkw2 = sl.CreateIndentifierLinkPage(fileName, keyword2,"dc.Identifier", collectionFolder,valueMap,linkMap);
+				double pre_cost = 0;
+				String keywordClone2 = keyword2;
+				String _keywordClone2 = keyword2;
+				String bkKeyWord2 = keyword2;
+				//System.out.println("before parsing kw2");
+				costModel cm = new costModel();
+				cm = removeUnusedCharacter(keywordClone2,pre_cost);
+				//System.out.println("after parsing kw2");
+				keywordClone2 = cm.getString();
+				pre_cost = cm.getCost();
+				
+				int spaceCounterFront2 = 0;
+				int spaceCounterEnd2 = 0;
+				
+				//System.out.println("before removing space from kw2");
+				while(true){
+					if(_keywordClone2.length()>1){
+					if(_keywordClone2.charAt(0)==' '){
+						_keywordClone2 = _keywordClone2.substring(1);
+						spaceCounterFront2++;
+					}
+					else{
+						if(_keywordClone2.charAt(_keywordClone2.length()-1)==' '){
+							_keywordClone2 = _keywordClone2.substring(0,_keywordClone2.length()-1);
+							spaceCounterEnd2++;
+						}
+						else{
+							break;
+						}
+					}}
+				else{
+					break;
+				}
+				}
+				/*
+				while(true){
+					if(_keywordClone2.contains("  ")){
+						_keywordClone2.replaceFirst("  "," ");
+					}
+					else{
+						break;
+					}
+				}*/
+				//System.out.println("after removing space from kw2");
+				
+				//System.out.println("after4");
+				int keyword2Length = keywordClone2.length();
+
+				if(keywordLength>(keyword2Length+2) || (keywordLength+2)<keyword2Length ){}
+				else{
+					//System.out.println("start edit distance: "+keywordClone + " " + keywordClone2);
+					//distance = ed.getLevenshteinDistance(keyword, keyword2);
+					distance = calculateEditDistance(keywordClone.toLowerCase().toCharArray(),keywordClone2.toLowerCase().toCharArray());
+					distance = distance + pre_cost;
+					//System.out.println("finish calculating edit distance");
+					if(distance<=3){
+						if(distanceMap.containsKey(_keywordClone)){
+							InternalLink il = (InternalLink)distanceMap.get(_keywordClone);
+							
+							String keywordHolder = _keywordClone2;
+							
+							while(true){
+								if(keywordHolder.contains("  ")){
+									keywordHolder = keywordHolder.replaceFirst("  ",spaceLeft+space+spaceRight+" ");
+								}
+								else{
+									break;
+								}
+							}
+							
+							for(int a = 0; a<spaceCounterFront2; a++){
+								keywordHolder = spaceLeft+space+spaceRight+keywordHolder;
+							}
+							for(int a = 0; a<spaceCounterEnd2; a++){
+								keywordHolder = keywordHolder+spaceLeft+space+spaceRight;
+							}
+							
+							InternalLink il2 = new InternalLink();
+							il2.setValue(keywordHolder);
+							if(suggestionMap.containsKey(bkKeyWord2)){
+								il2.increaseElement((String)suggestionMap.get(bkKeyWord2));
+								//System.out.println("input this url(3):"+(String)alistkw2.get(0));
+							}
+							else{
+								il2.increaseElement("&nbsp;");
+							}
+							
+							il.increaseNode(il2);
+							//il.increaseElement(keywordHolder);
+							distanceMap.put(_keywordClone, il);
+							
+							//il.increaseElement(keywordClone2);
+							//distanceMap.put(keyword, il);
+						}
+						else{
+							InternalLink il = new InternalLink();
+							String keywordHolder = _keywordClone;
+							
+							while(true){
+								if(keywordHolder.contains("  ")){
+									keywordHolder = keywordHolder.replaceFirst("  ",spaceLeft+space+spaceRight+" ");
+								}
+								else{
+									break;
+								}
+							}
+							
+							for(int a = 0; a<spaceCounterFront1; a++){
+								keywordHolder = spaceLeft+space+spaceRight+keywordHolder;
+							}
+							for(int a = 0; a<spaceCounterEnd1; a++){
+								keywordHolder = keywordHolder+spaceLeft+space+spaceRight;
+							}
+							
+							InternalLink il2 = new InternalLink();
+							il2.setValue(keywordHolder);
+							if(suggestionMap.containsKey(bkKeyWord)){
+								il2.increaseElement((String)suggestionMap.get(bkKeyWord));
+								//System.out.println("input this url(1):"+(String)alistkw1.get(0));
+							}
+							else{
+								il2.increaseElement("&nbsp;");
+							}
+							
+							il.increaseNode(il2);
+							//il.increaseElement(keywordHolder);
+							
+							keywordHolder = _keywordClone2;
+							
+							while(true){
+								if(keywordHolder.contains("  ")){
+									keywordHolder = keywordHolder.replaceFirst("  ",spaceLeft+space+spaceRight+" ");
+								}
+								else{
+									break;
+								}
+							}
+							for(int a = 0; a<spaceCounterFront2; a++){
+								keywordHolder = spaceLeft+space+spaceRight+keywordHolder;
+							}
+							for(int a = 0; a<spaceCounterEnd2; a++){
+								keywordHolder = keywordHolder+spaceLeft+space+spaceRight;
+							}
+							
+							InternalLink il3 = new InternalLink();
+							il3.setValue(keywordHolder);
+							if(suggestionMap.containsKey(bkKeyWord2)){
+								il3.increaseElement((String)suggestionMap.get(bkKeyWord2));
+								//System.out.println("input this url(2):"+(String)alistkw2.get(0));
+							}
+							else{
+								il3.increaseElement("&nbsp;");
+							}
+							
+							il.increaseNode(il3);
+							//il.increaseElement(keywordHolder);
+							distanceMap.put(_keywordClone, il);
+						}
+					}
+				}
+				//alistkw2.clear();
+			}
+			//alistkw1.clear();
+			//System.gc();
+		}
+		//System.out.println("after3");
+		time = System.currentTimeMillis() - time;
+		
+		System.out.println("The test took " + time + " milliseconds");
+		System.out.println("TotalLength: "+totalLength+"Avg. Length:"+totalLength/arrayListLength);
+		//arrayList.clear();
+		//System.gc();
+		//if(fileName.endsWith("dc.Title")){
+			//System.out.println(fileName +"Map Size"+ distanceMap.size(
+		//System.out.println("after2");
+		if(distanceMap.size()!=0){
+			generateHTML(distanceMap,fileName,metadataSetName);
+		}
+		}catch(Exception ex){ex.printStackTrace();}
+		//System.out.println("after1");
+	}
+	
+	
+	public int calculateEditDistance(char[] args1, char[] args2){
+        int n = args1.length; 
+        int m = args2.length; 
+        if (n == 0) {
+            return m;
+        }
+        else if (m == 0) {
+            return n;
+        }
+        
+        int[] p = new int[n + 1];
+    	int[] d = new int[n + 1]; 
+        int[] _d; 
+        
+
+        int i; 
+        int j; 
+
+        int cost; // cost
+
+        for (i = 0; i <= n; i++) {
+            p[i] = i;
+        }
+        for (j = 1; j <= m; j++) {
+
+            d[0] = j;
+            for (i = 1; i <= n; i++) {
+                cost = (args1[i-1] == args2[j-1]) ? 0 : 1;
+                d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1),
+                        p[i - 1] + cost);
+            }
+
+            // copy current distance counts to 'previous row' distance counts
+            _d = p;
+            p = d;
+            d = _d;
+        }
+        // our last action in the above loop was to switch d and p, so p now
+        // actually has the most recent cost counts
+        return p[n];
+	}
+
+    private String removeUnusedCharacter(String target){
+
+    	// remove \n 
+    	while(true){
+    	    if(target.contains("\\n")){
+    	    	target = target.replaceFirst("\\\\n","");
+    	    }
+    	    else{
+    	    	break;
+    	    }
+    	}
+    	
+    	//remove spaces at the end of string
+    	if(target.length()>1){
+    	while(true){
+    	   	if(target.length()>1){
+    	    if(target.charAt(target.length()-1)==' '){
+    	    	target = target.substring(0,target.length()-1);
+    	    }
+    	    else{
+    	    	break;
+    	    }
+    	   	}
+    	   	else{
+    	   		break;
+    	   	}
+        }
+    	}
+    	//remove leading spaces
+    	if(target.length()>1){
+        while(true){
+        	if(target.length()>1){
+    	   if(target.charAt(0)==' '){
+    		   target = target.substring(1,target.length());
+    	    }
+    	    else{
+    	    	break;
+    	    }}
+        	else{
+        		break;
+        	}
+        }
+    	}	 
+        //remove multiple spaces between words
+        while(true){
+    	   if(target.contains("  ")){
+    		   target = target.replaceFirst("  "," ");
+    	   }
+    	   else{
+    		   break;
+    	   }
+        }
+    	 return target;
+   }
+    	
+    	
+   private costModel removeUnusedCharacter(String target, double cost){
+    		
+    	costModel cm = new costModel();
+    	 
+    	// remove \n plus cost 
+    	while(true){
+    	    if(target.contains("\\n")){
+    	    	target = target.replaceFirst("\\\\n","");
+    	    	cost = cost + 0.2;
+    	    }
+    	    else{
+    	    	break;
+    	    }
+    	}
+    	
+    	//remove spaces at the end of string
+    	if(target.length()>1){
+    	while(true){
+    		if(target.length()>1){
+    	    if(target.charAt(target.length()-1)==' '){
+    	    	target = target.substring(0,target.length()-1);
+    	    	cost = cost + 0.2;
+    	    }
+    	    else{
+    	    	break;
+    	    }}
+    		else{
+    			break;
+    		}
+    	}
+    	}
+    	//remove leading spaces  
+    	if(target.length()>1){
+    	while(true){
+    		if(target.length()>1){
+    	    if(target.charAt(0)==' '){
+    	    	target = target.substring(1,target.length());
+    	    	cost = cost + 0.2;
+    	    }
+    	    else{
+    	    	break;
+    	    }}
+    		else{
+    			break;
+    		}
+    	}
+    	}
+        //remove multiple spaces between words
+    	while(true){
+    	    if(target.contains("  ")){
+    	    	target = target.replaceFirst("  "," ");
+    	    	cost = cost + 0.2;
+    	    }
+    	    else{
+    	    	break;
+    	    }
+    	}
+
+    		cm.setCost(cost);
+    		cm.setString(target);
+    	
+    	return cm;
+        }
+}
+
+
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/SearchLink.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/SearchLink.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/SearchLink.java	(revision 17184)
@@ -0,0 +1,338 @@
+package org.greenstone3.ms;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class SearchLink {
+
+	//final String path = "/research/cc108/greenstone3/web/mat/";
+	final String path = "/home/cc108/MRWks1/describeMessenger/";
+	
+	String collection ="";
+	String metadataElement ="";
+	//String core_element="";
+	PrintWriter out;
+	boolean status = true;
+	
+	public SearchLink(PrintWriter arg){
+		out = arg;
+	}
+	
+	public SearchLink(){
+		
+	}
+	
+	public boolean getStatus(){
+		return status;
+	}
+	public static void main(String[] args){
+		SearchLink sl = new SearchLink();	
+		//sl.CreateIndentifierLinkPage("dc.Creator", "Lowe, David J.", "dc.Identifier","poilkjm");
+		//sl.CreateIndentifierLinkPage("dc.Publisher2", "ResearchSpace@Auckland", "dc.Identifier1","vmeqlek");
+	}
+	
+	public ArrayList CreateIndentifierLinkPage(String metadataElement, String text, String identifier, String col, HashMap valueMap, HashMap linkMap){
+		collection = col;
+		//System.out.println("valueMap: "+valueMap.size()+ " linkMap: "+ linkMap.size());
+		this.metadataElement = metadataElement;
+		//Element ex = openfile(metadataElement,col);
+		try{
+		if(valueMap.size()==0){
+			status = false;
+			return new ArrayList();
+		}
+		else{
+			ArrayList alist = retrieveHASHID(valueMap,text);
+			if(alist.size()==0){
+				status = false;
+				return new ArrayList();
+			}
+			//ex = openfile(identifier,col);
+			if(linkMap.size()==0){
+				//out.write("<p>"+ identifier +" does not exist </p>");
+				status = false;
+				return new ArrayList();
+				//System.out.println(identifier + "does not exist2");
+				//return createResult(new ArrayList());
+			}
+			else{
+			ArrayList alist2 = retrieveHASHID(linkMap,alist,metadataElement);
+			//System.out.println("break3");
+			return alist2;
+			}
+		}
+		}catch(Exception ex){ex.printStackTrace(); return new ArrayList();}
+		//return "";
+	}
+	
+	
+	private Element openfile(String core_element, String collection){
+		
+		try{
+			DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+		    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+		    Document doc = docBuilder.newDocument();
+		    //Element rootNode = doc.
+		    //System.out.println(path+collection+"/metadataStats/"+core_element+".xml");
+		    doc = docBuilder.parse (new File(path+"/"+collection+"/metadataStats/"+core_element+".xml"));
+		    Element rootNode = doc.getDocumentElement();
+		    return rootNode;  
+		    }catch (Exception e) {
+	    	    //e.printStackTrace();
+		    	//out.write("<p>"+core_element +" does not exist </p>");
+		    	System.out.println(core_element + " does not exist1");
+		    	
+	    	    return null;
+		    }
+	}
+	
+	private ArrayList retrieveHASHID (HashMap hp, String text){
+		//ArrayList alist = new ArrayList();
+	
+     
+
+	    if(hp.containsKey(text)){
+	    	InternalLink il = (InternalLink) hp.get(text);
+	    	return il.retrieveList();
+	    }
+	    else{
+	    	return new ArrayList();
+	    }
+	}
+	
+	private ArrayList retrieveHASHID (HashMap hp, ArrayList arg,String metadataElement){
+     //System.out.println(metadataElement);
+		ArrayList alist = new ArrayList();
+		for(int i = 0; i<arg.size(); i++){
+			String text = (String)arg.get(i);
+			if(hp.containsKey(text)){
+				InternalLink il = (InternalLink) hp.get(text);
+				ArrayList arrayList = il.retrieveList();
+				if(arrayList.size()!=0){
+					alist.add(il.retrieveList().get(0));
+				}
+				else{
+					System.out.println(text);
+					alist.add("&nbsp;");
+				}
+				//return il.retrieveList();
+			}
+			/*
+			else{
+				return new ArrayList();
+			}
+			*/
+		}
+		return alist;
+	}
+	/*
+	private ArrayList retrieveHASHID (Element ex, ArrayList alist1){
+		ArrayList alist = new ArrayList();
+
+      	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+      	
+      	if(listOfFrequency.getLength()==0){
+      		//System.out.println("return 0");
+      		return alist;
+      	}
+      	
+      	for(int s=0; s<listOfFrequency.getLength() ; s++){
+      	   Node docNode = listOfFrequency.item(s);
+      	   NamedNodeMap NodeIDMap = docNode.getAttributes();
+      	   Node DocNodeID = NodeIDMap.item(0);
+      	   String DocID = DocNodeID.getNodeValue();
+
+      	   if(alist1.contains(DocID)){
+      		   //System.out.println("same");
+      		   Element xNode = (Element)docNode;
+          	   NodeList valueList = xNode.getElementsByTagName("ActualValue");
+          	   
+          	   
+          	   for(int y = 0; y<valueList.getLength(); y++){
+          		   Element valueElement = (Element)valueList.item(y);
+          		   NodeList textFNList = valueElement.getChildNodes();
+          		   String textValue = ((Node)textFNList.item(0)).getNodeValue();
+          		   //System.out.println(textValue);
+          		   if(textValue.startsWith("http://")){
+          			   alist.add(textValue);
+          			 break;
+          		   }
+       		    }
+      	   }
+        }
+      	
+		return alist;
+	}
+	*/
+	/*
+	private String createResult(ArrayList alist){
+		//System.out.println("test");\
+		String url = path+collection+"/"+metadataElement+"_result.html";
+		//System.out.println(url);
+		try{
+	    	//FileWriter fstream = new FileWriter("/home/cc108/MRWks1/Quality"+"/"+collection+"/"+"hello"+"_result.html");
+			//path /research/cc108/greenstone3/web/mat/
+		
+			//FileWriter fstream = new FileWriter(path+collection+"/"+metadataElement+"result.html");
+			FileWriter fstream = new FileWriter(url);
+		    BufferedWriter out = new BufferedWriter(fstream);
+		    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
+		    out.write("<html>\r\n");
+		    out.write("<head>\r\n<title>Result</title>\r\n");
+		    
+		    out.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n");
+		    out.write("</head>\r\n");
+		    out.write("<body>\r\n");
+		    out.write("<table border=\"1\" align=\"center\">\r\n");
+		    out.write("<tr>");
+	    	out.write("<td align=center> No.");
+	    	out.write("<td align=center> URL");
+		    //System.out.println(alist.size());
+		    for(int i = 0; i < alist.size(); i++){
+		    	out.write("<tr>");
+		    	out.write("<td align>"+(i+1));
+		    	out.write("<td align><a href=\""+(String)alist.get(i)+"\">"+(String)alist.get(i)+"</a>\n");
+		    	
+		    }
+		    out.write("</table></body></html>\r\n");
+		    out.close();
+		    fstream.close();
+		    //System.out.println("/home/cc108/MRWks1/Quality"+"/"+collection+"/"+metadataElement+"_result.html");
+		}catch(Exception ex){
+			//ex.printStackTrace();
+			out.write("<p> links cannot be generated </p>");
+		}
+		return url;
+	}
+	*/
+	
+	/////////////////////////////////////////////////////////////////////////////////////////////////////////////
+	public HashMap createValueMap(String core_element, String collection){
+	//System.out.println("Create value map1 "+core_element);
+ 	HashMap hp = new HashMap();
+ 	Element ex = openfile(core_element,collection);
+  	NodeList valueList = ex.getElementsByTagName("ActualValue");
+  	
+    for(int s=0; s<valueList.getLength() ; s++){
+      	   Element docNode = (Element)valueList.item(s);
+      	   NodeList NodeIDMap = docNode.getChildNodes();
+      	   Node DocNodeID = NodeIDMap.item(0);
+      	   String actualValue = DocNodeID.getNodeValue();
+      	   String DocID = DocNodeID.getParentNode().getParentNode().getAttributes().item(0).getNodeValue();
+  		 
+      	   if(hp.containsKey(actualValue)){
+      		 InternalLink il = (InternalLink) hp.get(actualValue);
+      		 il.increaseElement(DocID);
+      		 hp.put(actualValue, il);
+      	   }
+      	   else{
+      		   InternalLink il = new InternalLink();
+      		   il.setValue(actualValue);
+      		   il.increaseElement(DocID);
+      		   hp.put(actualValue, il);
+      	   }
+    	}
+	System.out.println("Create value map2 "+core_element);
+    return hp;
+	}
+	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+	public HashMap createLinkMap (String core_element, String collection){
+		//System.out.println("Create link map1 "+core_element);
+		//ArrayList alist = new ArrayList();
+		HashMap hp = new HashMap();
+		Element ex = openfile(core_element,collection);
+      	NodeList listOfFrequency = ex.getElementsByTagName("Document");
+      	
+      	if(listOfFrequency.getLength()==0){
+      		return hp;
+      	}
+      	
+      	for(int s=0; s<listOfFrequency.getLength() ; s++){
+      	   Node docNode = listOfFrequency.item(s);
+      	   NamedNodeMap NodeIDMap = docNode.getAttributes();
+      	   Node DocNodeID = NodeIDMap.item(0);
+      	   String DocID = DocNodeID.getNodeValue();
+
+
+      	   if(hp.containsKey(DocID)){
+
+      		   Element xNode = (Element)docNode;
+          	   NodeList valueList = xNode.getElementsByTagName("ActualValue");
+          	   
+          	   ArrayList alist = new ArrayList();
+          	   for(int y = 0; y<valueList.getLength(); y++){
+          		   Element valueElement = (Element)valueList.item(y);
+          		   NodeList textFNList = valueElement.getChildNodes();
+          		   String textValue = ((Node)textFNList.item(0)).getNodeValue();
+
+          		   if(textValue.startsWith("http://")){
+          			 InternalLink il = (InternalLink)hp.get(DocID);
+          			 //il.retrieveList();
+          			   //alist.add(textValue);
+          			 il.increaseElement(textValue);
+          			 break;
+          		   }
+       		    }
+      	   }
+      	   
+      	   
+      	   else {
+      		   InternalLink il = new InternalLink();
+      		   il.setValue(DocID);
+      		   
+    		   Element xNode = (Element)docNode;
+          	   NodeList valueList = xNode.getElementsByTagName("ActualValue");
+          	   
+          	   for(int y = 0; y<valueList.getLength(); y++){
+          		   Element valueElement = (Element)valueList.item(y);
+          		   NodeList textFNList = valueElement.getChildNodes();
+          		   String textValue = ((Node)textFNList.item(0)).getNodeValue();
+
+          		   if(textValue.startsWith("http://")){
+          			   //alist.add(textValue);
+          			 il.increaseElement(textValue);
+          			 break;
+          		   }
+       		    }
+          	   hp.put(DocID, il);
+      	   }
+        }
+    	System.out.println("Create value map2 "+core_element);
+		return hp;
+	}
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	////////////////////////////////////////////////////////////////////////////////////////////////////////////
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/SummaryPanel.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/SummaryPanel.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/SummaryPanel.java	(revision 17184)
@@ -0,0 +1,1273 @@
+package org.greenstone3.ms;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.Dimension;
+import javax.swing.*;
+import java.awt.Component;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2007</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class SummaryPanel extends JPanel {
+    
+    MetadataStats ms;
+    DataMaker dmx ;
+    ArrayList metadataNameList;
+    final int label_width = 320;
+    final int label_width1 = 200;
+    final int label_height = 30;
+    final int label_x_1 = 50;
+    final int label_x_2 = 325;
+    final int label_font_size = 16;
+    private int totalMetadataItem = 0;
+    private int totalDocument = 0;
+    private int totalMetadataElement = 0;
+    private HashMap jListDataModel = new HashMap();
+    
+    public SummaryPanel(MetadataStats me) {
+    	//System.out.println("step2");
+    	ms = me;
+    	dmx = new DataMaker(ms);
+    	metadataNameList = me.metadataNameList;
+    	totalDocument = dmx.getDocNum();
+    	calculateTotalMetadataItem();
+    	
+        try {
+            jbInit();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+    
+    private void calculateTotalMetadataItem(){
+    	HashMap hp = ms.getMetadataSetMap();
+    	Collection c = hp.values();
+    	Iterator ix = c.iterator();
+    	
+    	
+    	while(ix.hasNext()){
+    		MetadataSet mt = (MetadataSet) ix.next();
+    		totalMetadataElement = totalMetadataElement + mt.getIndexsList().size();
+    	}
+    	totalMetadataItem = totalMetadataElement *totalDocument;
+
+    }
+    
+    private void jbInit() throws Exception {
+  
+        JTabbedPane tabbedPane = new JTabbedPane();
+        //dmx = new DataMaker(ms);
+        dmx.setTotalDocNumber();
+  
+        elements = new String [metadataNameList.size()];
+
+        for(int i = 0; i<elements.length; i++){
+        	elements[i] = (String)metadataNameList.get(i);
+        }
+        Arrays.sort(elements);
+        jComboBox1 = new JComboBox(elements);
+        jComboBox2 = new JComboBox(sortOptions);
+        
+        HashMap mdsMap = ms.getMetadataSetMap();
+        MDS_list = new String[mdsMap.size()];
+        int counter = 0;
+        Set st = mdsMap.keySet();
+        Iterator it = st.iterator();
+        while(it.hasNext()){
+        	MDS_list[counter] = (String) it.next();
+        	counter++;
+        }
+  
+        jComboBox3 = new JComboBox(MDS_list);
+        //jList1 = new JList(listData);
+        
+        /*
+        TableModel model = new DefaultTableModel(dmx.AllInformation(),columnNames) {
+            public Class<?> getColumnClass(int column) {
+              return getValueAt(0, column).getClass();
+            }
+          };
+        //------------------------FIRST PANEL ---------------------------
+        final JTable table = new JTable(model);
+        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
+        table.setRowSorter(sorter);
+        table.setEnabled(false);
+        */
+	    //JScrollPane scrollPane = new JScrollPane(table);
+        
+	    JComponent panel1 = new JPanel();
+        panel1.setLayout(new AbsoluteLayout());
+       
+        jLabel27.setText("Number of Documents : ");
+        jLabel27.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jLabel28.setText("Number of Metadata Set : ");
+        jLabel28.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jLabel29.setText("Overall Completeness : ");
+        jLabel29.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jLabel30.setText("Date of Build : ");
+        jLabel30.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        jLabel35.setText(" ");
+        jLabel35.setHorizontalAlignment(JLabel.CENTER);
+        jLabel35.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jLabel36.setText(" ");
+        jLabel36.setHorizontalAlignment(JLabel.CENTER);
+        jLabel36.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jLabel37.setText(" ");
+        jLabel37.setHorizontalAlignment(JLabel.CENTER);
+        jLabel37.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jLabel38.setText(" ");
+        jLabel38.setHorizontalAlignment(JLabel.CENTER);
+        jLabel38.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        jLabel39.setText("Hide Empty Metadata Element");
+        jLabel39.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        jLabel40.setText("Hide Completed Metadata Element ");
+        jLabel40.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        jLabel41.setText("Hide Document with empty metadata element set");
+        jLabel41.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        jLabel42.setText("Hide Document with completed metadata element set");
+        jLabel42.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        
+	    jButton1.setText("Indexes");
+	    jButton1.setPreferredSize(new Dimension(150,20));
+        //jButton1.addActionListener(new SummaryPanel_jButton1_Adapter(this));
+        
+        ActionListener doIt1 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton1_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt1 = CursorController.createListener(this, doIt1);
+          jButton1.addActionListener(cursorDoIt1);
+          
+        jLabel31.setText("Metadata Set completeness");
+        jLabel31.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        jButton8.setText("Table");
+        jButton8.setPreferredSize(new Dimension(150,20));
+        jButton8.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton8.addActionListener(new SummaryPanel_jButton8_Adapter(this));
+        ActionListener doIt8 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton8_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt8 = CursorController.createListener(this, doIt8);
+          jButton8.addActionListener(cursorDoIt8);
+        
+        jButton9.setText("Customized Graph");
+        jButton9.setPreferredSize(new Dimension(150,20));
+        jButton9.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton9.addActionListener(new SummaryPanel_jButton9_Adapter(this));
+        ActionListener doIt9 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton9_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt9 = CursorController.createListener(this, doIt9);
+          jButton9.addActionListener(cursorDoIt9);
+
+        jButton11.setText("Web pages");
+        jButton11.setPreferredSize(new Dimension(150,20));
+        jButton11.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton11.addActionListener(new SummaryPanel_jButton11_Adapter(this));
+        
+       
+        ActionListener doIt11 = new ActionListener() {
+          public void actionPerformed(ActionEvent ae) {
+        	  jButton11_actionPerformed(ae);
+          }
+        };
+        ActionListener cursorDoIt11 = CursorController.createListener(this, doIt11);
+        jButton11.addActionListener(cursorDoIt11);
+
+        jList1 = new JList();
+        jCheckBox1 = new JCheckBox();
+        jCheckBox2 = new JCheckBox();
+        jCheckBox3 = new JCheckBox();
+        jCheckBox4 = new JCheckBox();
+        
+        jList1.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+ 
+        JPanel panel4 = new JPanel();
+        panel4.setLayout(new AbsoluteLayout());
+        panel4.setBorder(BorderFactory.createLineBorder(Color.black));
+        panel4.add(jLabel39,new AbsoluteConstraints(35,5,300,label_height));
+        panel4.add(jLabel40,new AbsoluteConstraints(35,40,300,label_height));
+        panel4.add(jLabel41,new AbsoluteConstraints(35,75,300,label_height));
+        panel4.add(jLabel42,new AbsoluteConstraints(35,110,300,label_height));
+        
+        panel4.add(jCheckBox1,new AbsoluteConstraints(10,7,20,20));
+        panel4.add(jCheckBox2,new AbsoluteConstraints(10,42,20,20));
+        panel4.add(jCheckBox3,new AbsoluteConstraints(10,77,20,20));
+        panel4.add(jCheckBox4,new AbsoluteConstraints(10,112,20,20));
+        
+
+        panel1.add(jButton1,new AbsoluteConstraints(50,650,100,30));
+        panel1.add(jButton8,new AbsoluteConstraints(160,650,100,30));
+        panel1.add(jButton9,new AbsoluteConstraints(270,650,100,30));
+        panel1.add(jButton11,new AbsoluteConstraints(380,650,100,30));
+        
+        panel1.add(jLabel27, new AbsoluteConstraints(label_x_1, 20, label_width, label_height));
+        panel1.add(jLabel28, new AbsoluteConstraints(label_x_1, 55, label_width, label_height));
+        panel1.add(jLabel29, new AbsoluteConstraints(label_x_1, 90, label_width, label_height));
+
+        panel1.add(jLabel31, new AbsoluteConstraints(label_x_1, 160, label_width, label_height));
+        panel1.add(jLabel35, new AbsoluteConstraints(label_x_2, 20, label_width1, label_height));
+        panel1.add(jLabel36, new AbsoluteConstraints(label_x_2, 55, label_width1, label_height));
+        panel1.add(jLabel37, new AbsoluteConstraints(label_x_2, 90, label_width1, label_height));
+        panel1.add(new JScrollPane(jList1), new AbsoluteConstraints(label_x_1, 200, 450, 200));
+        panel1.add(panel4, new AbsoluteConstraints(label_x_1, 410, 450, 150));
+        
+        //------------------------SECOND PANEL ---------------------------
+
+        jComboBox1.addItemListener(new SummaryPanel_jComboBox1_itemAdapter(this));
+        jComboBox1.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        jComboBox2.addItemListener(new SummaryPanel_jComboBox2_itemAdapter(this));
+        jComboBox2.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        JComponent panel2 = new JPanel();
+        panel2.setLayout(new AbsoluteLayout());
+
+        jLabel1.setText("Metadata : ");
+        jLabel1.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        jLabel2.setText("Unique Value : ");
+        jLabel2.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel3.setText(" ");
+        jLabel3.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel4.setText("Total times element used :");
+        jLabel4.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel5.setText(" ");
+        jLabel5.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel6.setText("No. of records containing element :");
+        jLabel6.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel7.setText(" ");
+        jLabel7.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel8.setText("Completeness %:");
+        jLabel8.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel9.setText(" ");
+        jLabel9.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel10.setText("Median : ");
+        jLabel10.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel11.setText(" ");
+        jLabel11.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel12.setText("Smallest number : ");
+        jLabel12.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel13.setText(" ");
+        jLabel13.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel14.setText("Largest number : ");
+        jLabel14.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel15.setText(" ");
+        jLabel15.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel16.setText("Average : ");
+        jLabel16.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel17.setText(" ");
+        jLabel17.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel18.setText("Mode : ");
+        jLabel18.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel19.setText(" ");
+        jLabel19.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel20.setText("Mode Frequency : ");
+        jLabel20.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel21.setText(" ");
+        jLabel21.setHorizontalAlignment(JLabel.CENTER);
+        
+        jLabel22.setText("Choose a sorting method : ");
+        jLabel22.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel23.setText("First Five :");
+        jLabel23.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+
+        // looks like it never be used
+        jLabel24.setText(" ");   
+        jLabel24.setBorder(BorderFactory.createLineBorder(Color.black));
+        
+        jLabel25.setText("Last Five :");
+        jLabel25.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+
+        // looks like it never be used
+        jLabel26.setText(" ");
+        jLabel26.setBorder(BorderFactory.createLineBorder(Color.black));
+              
+        jTextPane1.setSize(new Dimension(150,200));
+        jTextPane1.setOpaque(false);
+        jTextPane1.setAutoscrolls(true);
+        
+        jTextPane2.setSize(new Dimension(150,200));
+        jTextPane2.setAutoscrolls(true);
+        jTextPane2.setOpaque(false);
+        
+        jButton2.setText("Frequency chart1");
+        jButton2.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton2.addActionListener(new SummaryPanel_jButton2_Adapter(this));
+        ActionListener doIt2 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton2_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt2 = CursorController.createListener(this, doIt2);
+          jButton2.addActionListener(cursorDoIt2);
+        
+        jButton3.setText("Frequency chart2");
+        jButton3.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton3.addActionListener(new SummaryPanel_jButton3_Adapter(this));
+        ActionListener doIt3 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton3_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt3 = CursorController.createListener(this, doIt3);
+          jButton3.addActionListener(cursorDoIt3);
+        
+        /*
+        jButton4.setText("Show Documents");
+        jButton4.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        jButton4.addActionListener(new SummaryPanel_jButton4_Adapter(this));    
+        jButton5.setText("Chart 3");
+        jButton5.addActionListener(new SummaryPanel_jButton5_Adapter(this));
+        */
+
+        panel2.add(jLabel1, new AbsoluteConstraints(label_x_1, 20, label_width, label_height));
+        panel2.add(jComboBox1, new AbsoluteConstraints(label_x_2, 20, label_width1, label_height));
+        panel2.add(jLabel2, new AbsoluteConstraints(label_x_1, 55, label_width, label_height));
+        panel2.add(jLabel3, new AbsoluteConstraints(label_x_2, 55, label_width1, label_height));
+        panel2.add(jLabel4, new AbsoluteConstraints(label_x_1, 90, label_width, label_height));
+        panel2.add(jLabel5, new AbsoluteConstraints(label_x_2, 90, label_width1, label_height));
+        panel2.add(jLabel6, new AbsoluteConstraints(label_x_1, 125, label_width, label_height));
+        panel2.add(jLabel7, new AbsoluteConstraints(label_x_2, 125, label_width1, label_height));
+        panel2.add(jLabel8, new AbsoluteConstraints(label_x_1, 160, label_width, label_height));
+        panel2.add(jLabel9, new AbsoluteConstraints(label_x_2, 160, label_width1, label_height));
+        panel2.add(jLabel10, new AbsoluteConstraints(label_x_1, 195, label_width, label_height));
+        panel2.add(jLabel11, new AbsoluteConstraints(label_x_2, 195, label_width1, label_height));
+        panel2.add(jLabel12, new AbsoluteConstraints(label_x_1, 230, label_width, label_height));
+        panel2.add(jLabel13, new AbsoluteConstraints(label_x_2, 230, label_width1, label_height));
+        panel2.add(jLabel14, new AbsoluteConstraints(label_x_1, 265, label_width, label_height));
+        panel2.add(jLabel15, new AbsoluteConstraints(label_x_2, 265, label_width1, label_height));
+        panel2.add(jLabel16, new AbsoluteConstraints(label_x_1, 300, label_width, label_height));
+        panel2.add(jLabel17, new AbsoluteConstraints(label_x_2, 300, label_width1, label_height));
+        panel2.add(jLabel18, new AbsoluteConstraints(label_x_1, 335, label_width, label_height));
+        panel2.add(jLabel19, new AbsoluteConstraints(label_x_2, 335, label_width1, label_height));
+        panel2.add(jLabel20, new AbsoluteConstraints(label_x_1, 370, label_width, label_height));
+        panel2.add(jLabel21, new AbsoluteConstraints(label_x_2, 370, label_width1, label_height));
+        panel2.add(jLabel22, new AbsoluteConstraints(label_x_1, 405, label_width, label_height));
+        panel2.add(jComboBox2, new AbsoluteConstraints(label_x_2, 405, label_width1, label_height));
+        
+        
+        ////////////////////////////////////////////// first & last five
+        
+        panel2.add(jLabel23, new AbsoluteConstraints(label_x_1, 440, label_width, 30));
+        panel2.add(jTextPane1, new AbsoluteConstraints(label_x_2, 440, 200, 125));
+
+        panel2.add(jLabel25, new AbsoluteConstraints(label_x_1, 570, label_width, 30));
+        panel2.add(jTextPane2, new AbsoluteConstraints(label_x_2, 570, 200, 125));
+        
+        panel2.add(jButton2, new AbsoluteConstraints(30, 685, 185, 30));
+        panel2.add(jButton3, new AbsoluteConstraints(235, 685, 185, 30));     
+        
+        //////----------------------------THIRD panel
+        
+        jComboBox3.addItemListener(new SummaryPanel_jComboBox3_itemAdapter(this));
+        jLabel32.setText("Metadata Set: ");
+        jLabel32.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel33.setText("Indexes");
+        jLabel33.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jLabel34.setText("Completeness");
+        jLabel34.setFont(new java.awt.Font("Times New Roman", Font.BOLD, label_font_size));
+        
+        jButton7.setText("Statistics");
+        jButton7.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton6.addActionListener(new SummaryPanel_jButton7_Adapter(this));
+        ActionListener doIt7 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton7_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt7 = CursorController.createListener(this, doIt7);
+          jButton7.addActionListener(cursorDoIt7);
+          
+        jButton6.setText("Indexs");
+        jButton6.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton6.addActionListener(new SummaryPanel_jButton6_Adapter(this));
+        ActionListener doIt6 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton6_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt6 = CursorController.createListener(this, doIt6);
+          jButton6.addActionListener(cursorDoIt6);
+          
+        jComboBox3.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+      
+        jList2 = new JList();
+        jList2.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        jLabel43.setText("Hide Empty Metadata Element");
+        jLabel43.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        
+        jLabel44.setText("Hide Completed Metadata Element ");
+        jLabel44.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        
+        jLabel45.setText("Hide Document with empty metadata element set");
+        jLabel45.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        
+        jLabel46.setText("Hide Document with completed metadata element set");
+        jLabel46.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 12));
+        
+        jButton10.setText("Customized");
+        jButton10.setPreferredSize(new Dimension(150,20));
+        jButton10.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
+        //jButton10.addActionListener(new SummaryPanel_jButton10_Adapter(this));
+        ActionListener doIt10 = new ActionListener() {
+            public void actionPerformed(ActionEvent ae) {
+          	  jButton10_actionPerformed(ae);
+            }
+          };
+          ActionListener cursorDoIt10 = CursorController.createListener(this, doIt10);
+          jButton10.addActionListener(cursorDoIt10);
+        
+        JComponent panel3 = new JPanel();
+        panel3.setLayout(new AbsoluteLayout());
+        panel3.add(jLabel32, new AbsoluteConstraints(label_x_1, 20, label_width1, label_height));
+        panel3.add(jComboBox3, new AbsoluteConstraints(label_x_2, 20, label_width1, label_height));
+        panel3.add(jLabel33, new AbsoluteConstraints(label_x_1, 80, label_width, label_height));
+        panel3.add(jLabel34, new AbsoluteConstraints(250, 80, label_width1, label_height));
+        panel3.add(new JScrollPane(jList2), new AbsoluteConstraints(label_x_1, 120, 450, 250));
+                
+        panel3.add(jButton6,new AbsoluteConstraints(50,650,100,30));
+        panel3.add(jButton7,new AbsoluteConstraints(160,650,100,30));
+        panel3.add(jButton10,new AbsoluteConstraints(270,650,100,30));
+        
+        JPanel panel5 = new JPanel();
+        panel5.setLayout(new AbsoluteLayout());
+        panel5.setBorder(BorderFactory.createLineBorder(Color.black));
+        
+        panel5.add(jLabel43,new AbsoluteConstraints(35,5,250,label_height));
+        panel5.add(jLabel44,new AbsoluteConstraints(35,40,250,label_height));
+        panel5.add(jLabel45,new AbsoluteConstraints(35,75,250,label_height));
+        panel5.add(jLabel46,new AbsoluteConstraints(35,110,250,label_height));
+        
+        panel5.add(jCheckBox5,new AbsoluteConstraints(10,7,20,20));
+        panel5.add(jCheckBox6,new AbsoluteConstraints(10,42,20,20));
+        panel5.add(jCheckBox7,new AbsoluteConstraints(10,77,20,20));
+        panel5.add(jCheckBox8,new AbsoluteConstraints(10,112,20,20));
+
+        panel3.add(panel5, new AbsoluteConstraints(label_x_1, 410, 450, 150));
+   
+        //Add the tabbed pane to this panel.
+        add(tabbedPane);
+
+        tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+	
+        //Add the tabbed pane to this panel.
+        add(tabbedPane);
+	
+        //The following line enables to use scrolling tabs.
+        tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+	
+        tabbedPane.addTab("Overall Statistics", panel1);
+        tabbedPane.addTab("Element Information", panel2);
+        tabbedPane.addTab("Metadata Set", panel3);
+	
+        tabbedPane.setPreferredSize(new Dimension(550, 750));
+        this.setPreferredSize(new Dimension(570, 750));
+        //Add the tabbed pane to this panel.
+        tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+
+        overallPageUpdate();
+        updateSingleMetadataSetPage();
+    }
+    
+    
+    protected JComponent makeTextPanel(String text) {
+        JPanel panel = new JPanel(false);
+        JLabel filler = new JLabel(text);
+        filler.setHorizontalAlignment(JLabel.CENTER);
+        panel.setLayout(new GridLayout(1, 1));
+        panel.add(filler);
+        return panel;
+    }
+    
+    // Variable declaration
+    JTabbedPane tabbedPane = new JTabbedPane();
+    JTable jTable1 = new JTable();
+    
+    //String[] columnNames1 = {"Element","No.of element used","No. of record containing element", "Mean","Median","Unique Value"};
+    //String[] columnNames2 = {"Element","Min","Max","Avg","Mode","Mode frequency"};
+    String[] columnNames = {"Element","Total times element used","No. of record \ncontaining element", "Mean","Median","Unique Value","Min","Max","Avg","Mode","Mode frequency"};
+    String[] sortOptions = {"ASCII","Frequency-based"};
+    //String[] mds = {"Dublin","Extracted"};
+
+    //CardLayout cardLayout1 = new CardLayout();
+    JLabel jLabel1 = new JLabel();
+    JLabel jLabel2 = new JLabel();
+    JLabel jLabel3 = new JLabel();
+    JLabel jLabel4 = new JLabel();
+    JLabel jLabel5 = new JLabel();
+    JLabel jLabel6 = new JLabel();
+    JLabel jLabel7 = new JLabel();
+    JLabel jLabel8 = new JLabel();
+    JLabel jLabel9 = new JLabel();
+    JLabel jLabel10 = new JLabel();
+    JLabel jLabel11 = new JLabel();
+    JLabel jLabel12 = new JLabel();
+    JLabel jLabel13 = new JLabel();
+    JLabel jLabel14 = new JLabel();
+    JLabel jLabel15 = new JLabel();
+    JLabel jLabel16 = new JLabel();
+    JLabel jLabel17 = new JLabel();
+    JLabel jLabel18 = new JLabel();
+    JLabel jLabel19 = new JLabel();
+    JLabel jLabel20 = new JLabel();
+    JLabel jLabel21 = new JLabel();
+    JLabel jLabel22 = new JLabel();
+    JLabel jLabel23 = new JLabel();
+    JLabel jLabel24 = new JLabel();
+    JLabel jLabel25 = new JLabel();
+    JLabel jLabel26 = new JLabel();
+    /////////////////////////// -- more
+    JLabel jLabel27 = new JLabel();//left panel1
+    JLabel jLabel28 = new JLabel();
+    JLabel jLabel29 = new JLabel();
+    JLabel jLabel30 = new JLabel();
+    JLabel jLabel31 = new JLabel();
+    
+    JLabel jLabel35 = new JLabel(); //right
+    JLabel jLabel36 = new JLabel();
+    JLabel jLabel37 = new JLabel();
+    JLabel jLabel38 = new JLabel();
+    JButton jButton8 = new JButton();
+    JButton jButton9 = new JButton();
+    
+    JCheckBox jCheckBox1 = new JCheckBox();
+    JCheckBox jCheckBox2 = new JCheckBox();
+    JCheckBox jCheckBox3 = new JCheckBox();
+    JCheckBox jCheckBox4 = new JCheckBox();
+    JLabel jLabel39 = new JLabel();
+    JLabel jLabel40 = new JLabel();
+    JLabel jLabel41 = new JLabel();
+    JLabel jLabel42 = new JLabel();
+    JButton jButton11 = new JButton();
+    
+    JLabel jLabel32 = new JLabel();//panel3
+    JLabel jLabel33 = new JLabel();
+    JLabel jLabel34 = new JLabel();
+    JButton jButton6 = new JButton();
+    JButton jButton7 = new JButton();
+
+    JCheckBox jCheckBox5 = new JCheckBox();
+    JCheckBox jCheckBox6 = new JCheckBox();
+    JCheckBox jCheckBox7 = new JCheckBox();
+    JCheckBox jCheckBox8 = new JCheckBox();
+    
+    JLabel jLabel43 = new JLabel();
+    JLabel jLabel44 = new JLabel();
+    JLabel jLabel45 = new JLabel();
+    JLabel jLabel46 = new JLabel();
+    JButton jButton10 = new JButton();
+    ///////////////////////////////--more ends
+    JButton jButton1 = new JButton();
+    JButton jButton2 = new JButton();
+    JButton jButton3 = new JButton();
+    JButton jButton4 = new JButton();
+    JButton jButton5 = new JButton();
+    JTextPane jTextPane1 = new JTextPane(); 
+    JTextPane jTextPane2 = new JTextPane(); 
+    
+    JTextArea jTextArea1 = new JTextArea();
+    JTextArea jTextArea2 = new JTextArea();
+    Color cl =Color.black;
+    String[] elements;
+    String[] MDS_list;
+    
+    JComboBox jComboBox1;
+    JComboBox jComboBox2;
+    JComboBox jComboBox3; 
+    
+
+    
+    JList jList1;
+    JList jList2;
+    
+    public void jComboBox1_itemStateChanged(ItemEvent e) {
+	//Object item = e.getItem();
+	jLabel21.setText(dmx.getDocNum()+"");
+	update(jComboBox1.getSelectedItem().toString(),jComboBox2.getSelectedItem().toString());
+	FirstAndLastFive(jComboBox1.getSelectedItem().toString(),jComboBox2.getSelectedItem().toString());
+    }
+    
+    public void jComboBox2_itemStateChanged(ItemEvent e) {
+    	FirstAndLastFive(jComboBox1.getSelectedItem().toString(),jComboBox2.getSelectedItem().toString());
+    }
+    
+    public void jComboBox3_itemStateChanged(ItemEvent e) {
+    	updateSingleMetadataSetPage();
+    }
+    
+    private void updateSingleMetadataSetPage(){
+
+    	DataMaker dm = new DataMaker(ms);
+    	dm.setTotalDocNumber();
+
+    	String mdsIndexsName = jComboBox3.getSelectedItem().toString();
+    	HashMap hp = ms.getMetadataSetMap();
+    	MetadataSet msx = (MetadataSet)hp.get(mdsIndexsName);
+    	ArrayList nameList = msx.getIndexsList();
+    	String[][] MetadataData = new String[nameList.size()][2]; 
+    	for(int i = 0; i<nameList.size(); i++){
+    		MetadataData[i][0] = (String)nameList.get(i);
+    		MetadataData[i][1] = new String(dm.Mean((String)nameList.get(i))+" %");
+    		if(MetadataData[i][1].indexOf(".")==2){
+    			MetadataData[i][1] = "  "+MetadataData[i][1];
+    		}
+    		else if(MetadataData[i][1].indexOf(".")==1){
+    			MetadataData[i][1] = "    "+MetadataData[i][1];
+    		}
+    	}
+    	jList2.setListData(MetadataData);
+    	jList2.setCellRenderer(new MyCellRenderer()); 
+    	jListDataModel.put("jList2",MetadataData);
+
+    }
+    private void FirstAndLastFive(String element_name, String sort){
+    	DataMaker dm = new DataMaker(ms);
+    	dm.setTotalDocNumber();
+    	
+    	String[] temp = dm.getSortList(element_name,sort);
+    	String[] temp2 = {" "," "," "," "," "};
+    	int length = 0;
+    	if(temp.length>=5){length=5;}
+    	else if(temp.length<5){length = temp.length;}
+            
+    	for(int i =0; i<length; i++){
+    	    temp2[i] = temp[i];
+    	}
+
+    	jTextPane1.setText("");
+    	jTextPane1.setText("1. "+temp2[0]+"\n2. "+temp2[1]+"\n3. "+temp2[2]+"\n4. "+temp2[3]+"\n5. "+temp2[4]);  
+    	 	
+    	// Last five value
+    	String[] temp3 = {" "," "," "," "," "};
+    	length = 0;
+    	int start = temp.length;
+    	if(temp.length>=5){length= 5;}
+    	else if(temp.length<5){length = temp.length;}
+            
+    	for(int i = 0; i<length; i++){
+    	    temp3[i] = temp[start-1];
+    	    start--;
+    	}
+
+    	jTextPane2.setText("");
+    	jTextPane2.setText("1. "+temp3[0]+"\n2. "+temp3[1]+"\n3. "+temp3[2]+"\n4. "+temp3[3]+"\n5. "+temp3[4]);  
+    	
+    }
+    
+    private void overallPageUpdate(){
+    	DataMaker dm = new DataMaker(ms);
+
+    	jTextArea2.setText("");
+    	ArrayList wholeList = new ArrayList();
+    	HashMap hp = ms.getMetadataSetMap();
+    	Collection c = hp.values();
+    	Iterator i = c.iterator();
+    	//System.out.println(hp.size()+" 111?");
+    	int counter = 0;
+    	String[][] MetadataData = new String[c.size()][2];
+    	while(i.hasNext()){
+    		MetadataSet mds  = (MetadataSet)i.next();
+    		//System.out.println(mds.getName());
+    		wholeList.add(mds);
+    		ArrayList newMDS  = new ArrayList();
+    		newMDS.add(mds);
+    		MetadataData[counter][0] = mds.getName();
+    		//System.out.println(MetadataData[counter][0]);
+    		//System.out.println(MetadataData[counter][0]+"????"+newMDS.size());
+    		MetadataData[counter][1] = dm.getSingleMetadataSetCompleteness(newMDS)+" %";
+    		//System.out.println(MetadataData[counter][1]);
+    		counter++;
+    	}
+    	System.out.println(hp.size()+" 222?");
+    	jLabel35.setText(dm.getDocNum()+"");
+    	jLabel36.setText(ms.getMetadataSetMap().size()+"");
+    	jLabel37.setText(dm.getSingleMetadataSetCompleteness(wholeList)+" %");
+    	jList1.setListData(MetadataData);
+    	jList1.setCellRenderer(new MyCellRenderer()); 
+    	jListDataModel.put("jList1",MetadataData);
+    }
+    
+    static class MyCellRenderer extends JPanel implements ListCellRenderer{ 
+        JLabel left, middle, right; 
+        MyCellRenderer() { 
+           setLayout(new GridLayout(1, 2)); 
+           left = new JLabel(); 
+           
+           right = new JLabel(); 
+           left.setOpaque(true); 
+
+           right.setOpaque(true); 
+           add(left); 
+           add(right); 
+        } 
+         
+        public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus){ 
+           String leftData    = ((String[])value)[0]; 
+           String rightData    = ((String[])value)[1]; 
+           left.setText(leftData); 
+
+           right.setText(rightData); 
+           if(isSelected){ 
+              left.setBackground(list.getSelectionBackground()); 
+              left.setForeground(list.getSelectionForeground()); 
+              right.setBackground(list.getSelectionBackground()); 
+              right.setForeground(list.getSelectionForeground()); 
+           } 
+           else{ 
+              left.setBackground(list.getBackground()); 
+              left.setForeground(list.getForeground()); 
+              right.setBackground(list.getBackground()); 
+              right.setForeground(list.getForeground()); 
+           } 
+           setEnabled(list.isEnabled()); 
+           setFont(list.getFont()); 
+           return this; 
+        } 
+     }
+    private void update(String element_name, String sort){
+	DataMaker dm = new DataMaker(ms);
+	dm.setTotalDocNumber();
+	
+	
+	jLabel3.setText(dm.getDistinctNumber(element_name)+"");
+	jLabel5.setText(dm.getFrequency(element_name)+"");
+	jLabel7.setText(dm.getDocumentUsedElement(element_name)+"");
+	jLabel9.setText(dm.Mean(element_name)+"");
+	jLabel11.setText(dm.Median(element_name)+"");
+	jLabel13.setText(dm.getMinRange(element_name)+"");
+	jLabel15.setText(dm.getMaxRange(element_name)+"");
+	jLabel17.setText(dm.Average(element_name)+"");
+	jLabel19.setText(dm.getMode(element_name)+"");
+	jLabel21.setText(dm.ModeFrequency(element_name)+"");
+    }	
+    
+    public void jButton1_actionPerformed(ActionEvent actionevent) {
+
+    	ArrayList alist = new ArrayList();
+    	for(int a = 0; a<elements.length; a++){
+    		alist.add(dmx.getMetadataRows(elements[a]));
+    	}
+
+    	String[] ids = dmx.getDocumentIDs("archivedir");
+    	new DrawSymbolAxis("Total Document: "+totalDocument +" Total Element:"+totalMetadataElement + " Total Metadata Item:"+totalMetadataItem,elements,ids,alist);
+    }
+    
+    
+    public void jButton2_actionPerformed(ActionEvent actionevent) {
+    	String item = jComboBox1.getSelectedItem().toString();
+    	new DrawXYChart("",item,dmx.getDistinctValueMap(item),1);
+    }
+    
+    public void jButton3_actionPerformed(ActionEvent actionevent) {
+    	String item = jComboBox1.getSelectedItem().toString();
+    	new DrawXYChart("",item,dmx.getDocFrequencyMap(item),2);
+    }
+    
+    public void jButton6_actionPerformed(ActionEvent actionevent) {
+    	String mdsName = jComboBox3.getSelectedItem().toString();
+    	HashMap hp = ms.getMetadataSetMap();
+    	MetadataSet msx = (MetadataSet)hp.get(mdsName);
+    	ArrayList al = msx.getIndexsList();
+    	String[] tempx = new String[al.size()];
+     	
+    	for(int a = 0; a<al.size(); a++){
+    		tempx[a] = (String)al.get(a);
+    	}
+    	//String item = tempx[0];
+    	ArrayList alist = new ArrayList();
+    	for(int a = 0; a<tempx.length; a++){
+    		alist.add(dmx.getMetadataRows(tempx[a]));
+    	}
+    	//String[] ids = dmx.getDocumentIDs(item);
+    	String[] ids = dmx.getDocumentIDs("archivedir");
+    	int totalDoc = ids.length;
+    	int totalElement = tempx.length;
+    	int totalItem = totalDoc * totalElement;
+    	new DrawSymbolAxis("Total Document: "+ totalDoc +" Total Element:"+totalElement  + " Total Metadata Item:"+totalItem,tempx,ids,alist);
+    }
+    
+    public void jButton7_actionPerformed(ActionEvent actionevent) {
+    	
+    	DataMaker dm = new DataMaker(ms);
+    	String mdsName = jComboBox3.getSelectedItem().toString();
+    	HashMap hp = ms.getMetadataSetMap();
+    	MetadataSet mds = (MetadataSet)hp.get(mdsName);
+    	ArrayList alist = mds.getIndexsList();
+    	Object[][] dataset = dm.getMetadataInfo(mds);
+    	new metadatatable(columnNames,dataset);
+    }
+    
+    public void jButton8_actionPerformed(ActionEvent actionevent) {
+    	DataMaker dm = new DataMaker(ms);
+    	Object[][] dataset = dm.AllInformation();
+    	new metadatatable(columnNames,dataset);
+    }
+    
+    public void jButton9_actionPerformed(ActionEvent actionevent) {
+    	DataMaker dm = new DataMaker(ms);
+    	String[] metaDataElementName = (String[])elements.clone();	
+    	//String item = metaDataElementName[0]; //metadataElement Name
+    	//String[] ids = dmx.getDocumentIDs(item).clone();
+    	String[] ids = dmx.getDocumentIDs("archivedir");
+    	
+    	ArrayList alist = new ArrayList();
+    	for(int a = 0; a<elements.length; a++){
+    		alist.add(dmx.getMetadataRows(elements[a]));
+    	}
+    	
+    	int totalDocx = ids.length;
+    	int totalElementx = elements.length;
+    	int totalItemx = totalDocx * totalElementx;
+    	
+    	if(jCheckBox1.isSelected() == false && jCheckBox2.isSelected() == false && jCheckBox3.isSelected() == false && jCheckBox4.isSelected() == false){
+    		new DrawSymbolAxis("Total Document: "+ totalDocx +" Total Element:"+totalElementx  + " Total Metadata Item:"+totalItemx,elements,ids,alist);
+    	}
+    	
+    	else{
+    	ArrayList nameList = new ArrayList();
+    	
+    	
+    	if(jCheckBox1.isSelected() == true){
+        	alist = new ArrayList();
+        	nameList = new ArrayList();
+    		for(int i = 0; i< metaDataElementName.length; i++){
+    			if(!dm.IsElementEmpty(metaDataElementName[i])){
+    				alist.add(dmx.getMetadataRows(metaDataElementName[i]));
+    				nameList.add(metaDataElementName[i]);
+    			}
+    		}
+    		metaDataElementName = new String[nameList.size()];
+    		for(int i = 0; i< nameList.size(); i++){
+    			metaDataElementName[i] = nameList.get(i).toString();
+    		}
+    		
+    	}
+    	
+
+    	if(jCheckBox2.isSelected() == true){
+        	alist = new ArrayList();
+        	nameList = new ArrayList();
+    		for(int i = 0; i< metaDataElementName.length; i++){
+    			if(!dm.IsElementFull(metaDataElementName[i])){
+    				alist.add(dmx.getMetadataRows(metaDataElementName[i]));
+    				nameList.add(metaDataElementName[i]);
+    			}
+    		}
+    		metaDataElementName = new String[nameList.size()];
+    		for(int i = 0; i< nameList.size(); i++){
+    			metaDataElementName[i] = nameList.get(i).toString();
+    		}
+    }
+    	
+    	if(jCheckBox3.isSelected() == true){
+    		System.out.println(ids.length+" check3");
+    		alist = dmx.removeDocument(alist, ids, 0);
+    		ArrayList idList = dmx.getRemovedID();
+    		ArrayList newIDList = new ArrayList();
+    		for(int i = 0; i< ids.length; i++){
+    	  			if(!idList.contains(ids[i])){
+    	  				newIDList.add(ids[i]);
+    	  			}
+    		}
+    		ids = new String[newIDList.size()];
+    		for(int i = 0; i<newIDList.size(); i++){
+    			ids[i] = newIDList.get(i).toString();
+    		}
+
+    	}
+    	
+    	if(jCheckBox4.isSelected() == true){
+    		System.out.println(ids.length+" check4-1");
+    		alist = dmx.removeDocument(alist, ids ,1);
+    		ArrayList idList = dmx.getRemovedID();
+    		System.out.println(idList.size()+" check4-2");
+    		ArrayList newIDList = new ArrayList();
+    		for(int i = 0; i< ids.length; i++){
+    	  			if(!idList.contains(ids[i])){
+    	  				newIDList.add(ids[i]);
+    	  			}
+    		}
+    		ids = new String[newIDList.size()];
+    		for(int i = 0; i<newIDList.size(); i++){
+    			ids[i] = newIDList.get(i).toString();
+    		}
+
+    	}
+    	
+    	
+    	totalDocx = ids.length;
+    	totalElementx = metaDataElementName.length;
+    	totalItemx = totalDocx * totalElementx;
+    	new DrawSymbolAxis("Total Document: "+ totalDocx +" Total Element:"+totalElementx  + " Total Metadata Item:"+totalItemx,metaDataElementName,ids,alist);
+    	}
+    	System.out.println(jList1.getModel().getSize());
+    	System.out.println(jCheckBox2.isSelected());
+    	System.out.println(jCheckBox3.isSelected());
+    	System.out.println(jCheckBox4.isSelected()+"\n\n");
+    }
+    
+    
+    public void jButton10_actionPerformed(ActionEvent actionevent) {
+    	System.out.println(" j button 10 is pressed");
+    	System.out.println(jList2.getSelectedIndices().length);
+    	DataMaker dm = new DataMaker(ms);
+    	String elemenetName = jComboBox3.getSelectedItem().toString();
+    	System.out.println(elemenetName);
+    	HashMap elementMap = ms.getMetadataSetMap();
+    	MetadataSet elementSet = (MetadataSet)elementMap.get(elemenetName);
+    	//System.out.println(elementSet.getIndexsList().size());
+    	ArrayList alist2 = elementSet.getIndexsList();
+    	String[] metaDataElementName = new String[alist2.size()];
+    	for(int i = 0; i< alist2.size(); i++){
+    		metaDataElementName[i] = alist2.get(i).toString();
+    		System.out.println(metaDataElementName[i]);
+    	}
+    	
+    	//String item = metaDataElementName[0]; //metadataElement Name
+    	//String[] ids = dmx.getDocumentIDs(item);
+    	String[] ids = dmx.getDocumentIDs("archivedir");
+    	
+    	ArrayList alist = new ArrayList();
+    	for(int a = 0; a<metaDataElementName.length; a++){
+    		alist.add(dmx.getMetadataRows(metaDataElementName[a]));
+    	}
+    	if(jList2.getSelectedIndices().length>0){
+    		//hhhhhhhhhh
+    		int[] location = jList2.getSelectedIndices();
+    		String[][] list = (String[][])jListDataModel.get("jList2");
+    		metaDataElementName = new String[location.length];
+        	for(int i = 0; i< location.length; i++){
+        		int x = location[i];
+        		metaDataElementName[i] = list[x][0];
+        		System.out.println(metaDataElementName[i]);
+        	}
+        	//item = metaDataElementName[0];
+        	//ids = dmx.getDocumentIDs(item);
+        	ids = dmx.getDocumentIDs("archivedir");
+    		//metaDataElementName = jList2
+    	}
+    	
+    	int totalDocx = ids.length;
+    	int totalElementx = metaDataElementName.length;
+    	int totalItemx = totalDocx * totalElementx;
+    	
+    	if(jCheckBox5.isSelected() == false && jCheckBox6.isSelected() == false && jCheckBox7.isSelected() == false && jCheckBox8.isSelected() == false){
+    		new DrawSymbolAxis("Total Document: "+ totalDocx +" Total Element:"+totalElementx  + " Total Metadata Item:"+totalItemx,metaDataElementName,ids,alist);
+    	}
+    	
+    	else{
+
+    	ArrayList nameList = new ArrayList();
+    	
+    	
+    	if(jCheckBox5.isSelected() == true){
+        	alist = new ArrayList();
+        	nameList = new ArrayList();
+    		for(int i = 0; i< metaDataElementName.length; i++){
+    			//System.out.println(dm.IsElementEmpty(metaDataElementName[i])+ "  element1 "+ metaDataElementName[i]);
+    			if(!dm.IsElementEmpty(metaDataElementName[i])){
+    				alist.add(dmx.getMetadataRows(metaDataElementName[i]));
+    				nameList.add(metaDataElementName[i]);
+    			}
+    		}
+    		metaDataElementName = new String[nameList.size()];
+    		for(int i = 0; i< nameList.size(); i++){
+    			metaDataElementName[i] = nameList.get(i).toString();
+    		}
+
+    	}
+    	
+
+    	if(jCheckBox6.isSelected() == true){
+        	alist = new ArrayList();
+        	nameList = new ArrayList();
+    		for(int i = 0; i< metaDataElementName.length; i++){
+    			//System.out.println(dm.IsElementFull(metaDataElementName[i])+ "  element2 "+ metaDataElementName[i]);
+    			if(!dm.IsElementFull(metaDataElementName[i])){
+    				alist.add(dmx.getMetadataRows(metaDataElementName[i]));
+    				nameList.add(metaDataElementName[i]);
+    			}
+    		}
+    		metaDataElementName = new String[nameList.size()];
+    		for(int i = 0; i< nameList.size(); i++){
+    			metaDataElementName[i] = nameList.get(i).toString();
+    		}
+
+    	}
+    	
+    	if(jCheckBox7.isSelected() == true){
+    		alist = dmx.removeDocument(alist, ids , 0);
+    		ArrayList idList = dmx.getRemovedID();
+    		ArrayList newIDList = new ArrayList();
+    		for(int i = 0; i< ids.length; i++){
+    	  			if(!idList.contains(ids[i])){
+    	  				newIDList.add(ids[i]);
+    	  			}
+    		}
+    		ids = new String[newIDList.size()];
+    		for(int i = 0; i<newIDList.size(); i++){
+    			ids[i] = newIDList.get(i).toString();
+    		}
+
+    	}
+    	
+    	if(jCheckBox8.isSelected() == true){
+    		alist = dmx.removeDocument(alist, ids , 1);
+    		ArrayList idList = dmx.getRemovedID();
+    		ArrayList newIDList = new ArrayList();
+    		for(int i = 0; i< ids.length; i++){
+    	  			if(!idList.contains(ids[i])){
+    	  				newIDList.add(ids[i]);
+    	  			}
+    		}
+    		ids = new String[newIDList.size()];
+    		for(int i = 0; i<newIDList.size(); i++){
+    			ids[i] = newIDList.get(i).toString();
+    		}
+
+    	}
+    	
+    	totalDocx = ids.length;
+    	totalElementx = metaDataElementName.length;
+    	totalItemx = totalDocx * totalElementx;
+    	
+    	new DrawSymbolAxis("Total Document: "+ totalDocx +" Total Element:"+totalElementx  + " Total Metadata Item:"+totalItemx,metaDataElementName,ids,alist);
+    	}
+    	
+
+    }
+    
+    
+    public void jButton11_actionPerformed(ActionEvent actionevent) {
+    	
+    	/*
+    	//long startTime=System.currentTimeMillis();	
+    	DataMaker dm = new DataMaker(ms);
+    	String[] metaDataElementName = (String[])elements.clone();	
+    	String item = metaDataElementName[0]; //metadataElement Name
+    	//String[] ids = dm.getDocumentIDs(item);
+    	String[] ids = dmx.getDocumentIDs("archivedir");
+    	
+    	ArrayList alist = new ArrayList();
+    	for(int a = 0; a<elements.length; a++){
+    		alist.add(dm.getMetadataRows(elements[a]));
+    	}
+    	//System.out.println(alist.size()+ " " +ids.length+" "+metaDataElementName.length);   	
+    	PrintHTML phtml = new PrintHTML(ms);
+
+    	long startTime=System.currentTimeMillis();
+    	phtml.generateAllPossibleGraph(alist,ids,metaDataElementName,"extracted");
+    	phtml.generateAllPossibleGraph(alist,ids,metaDataElementName,"dublin");
+    	phtml.generateAllPossibleGraph(alist,ids,metaDataElementName,"both");
+    	long endTime=System.currentTimeMillis();
+    	System.out.println("Total time taken for generating overall Statistics Page "+(endTime-startTime)+ " millisec");
+
+    	//phtml.generateAllPossibleGraph(alist,ids,metaDataElementName);
+ 
+    	//startTime=System.currentTimeMillis();
+    	phtml.generateOverallStatisticsPage();
+    	//endTime=System.currentTimeMillis();
+    	//System.out.println("Total time taken for generating overall Statistics Page "+(endTime-startTime)+ " millisec");
+    	//System.out.println("hello" + dmx.Mean("dc.Title"));
+    	Collection cx = ms.getMetadataSetMap().values();
+    	Iterator ix = cx.iterator();
+    	//startTime=System.currentTimeMillis();
+    	while(ix.hasNext()){
+    		MetadataSet temp = (MetadataSet)ix.next();
+    		phtml.WriteMetadataSetDetailHTML(temp);
+    		phtml.generateMetadataElementDetailPage(temp);
+    	}
+    	//endTime=System.currentTimeMillis();
+    	//System.out.println("Total time taken for generating metadata set detail Page "+(endTime-startTime)+ " millisec");
+    	//long endTime=System.currentTimeMillis();
+    	//System.out.println("Total time taken for generating all Possible Graph "+(endTime-startTime)+ " millisec");
+    */
+    
+    }
+
+}	
+
+
+class SummaryPanel_jComboBox1_itemAdapter implements ItemListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jComboBox1_itemAdapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void itemStateChanged(ItemEvent e) {
+        adaptee.jComboBox1_itemStateChanged(e);
+    }
+}
+
+class SummaryPanel_jComboBox2_itemAdapter implements ItemListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jComboBox2_itemAdapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void itemStateChanged(ItemEvent e) {
+        adaptee.jComboBox2_itemStateChanged(e);
+    }
+}
+
+class SummaryPanel_jComboBox3_itemAdapter implements ItemListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jComboBox3_itemAdapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void itemStateChanged(ItemEvent e) {
+        adaptee.jComboBox3_itemStateChanged(e);
+    }
+}
+
+class SummaryPanel_jButton1_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton1_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton1_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton2_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton2_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton2_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton3_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton3_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton3_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton6_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton6_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton6_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton7_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton7_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton7_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton8_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton8_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton8_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton9_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton9_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton9_actionPerformed(e);
+    }
+}
+
+class SummaryPanel_jButton10_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton10_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton10_actionPerformed(e);
+    }
+}
+
+
+class SummaryPanel_jButton11_Adapter implements ActionListener {
+    private SummaryPanel adaptee;
+    SummaryPanel_jButton11_Adapter(SummaryPanel adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton11_actionPerformed(e);
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/collectionChooser.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/collectionChooser.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/collectionChooser.java	(revision 17184)
@@ -0,0 +1,94 @@
+package org.greenstone3.ms;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class collectionChooser extends JFrame {
+	
+    JPanel jPanel;
+    JButton jButton1;
+    JComboBox collectionComboBox;
+    
+    public collectionChooser() {
+	
+    	this.setTitle("Choose a collection");
+
+    	DescribeMessager dm = new DescribeMessager();
+        dm.describe();
+        Node cList = dm.getCollectionList();
+        Element collectionList = (Element) cList;
+        NodeList collectionNameList = collectionList.getElementsByTagName("collection");
+        String[] collectionStrings = new String[collectionNameList.getLength()];
+        
+        for(int i = 0; i< collectionNameList.getLength(); i++){
+        	Node nameNode = collectionNameList.item(i);
+        	collectionStrings[i] = nameNode.getAttributes().item(0).getNodeValue();
+        }
+
+      
+        jButton1 = new JButton("Enter");
+        jButton1.setPreferredSize(new Dimension(150,30));
+        jButton1.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        jButton1.addActionListener(new collectionChooser_jButton1_Adapter(this));
+        
+        collectionComboBox = new JComboBox(collectionStrings);
+        collectionComboBox.setSelectedIndex(0);
+        collectionComboBox.setPreferredSize(new Dimension(150,30));
+        collectionComboBox.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 16));
+        
+        JLabel text = new JLabel();
+        text.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 14));
+        text.setText("Available Collection");
+        text.setPreferredSize(new Dimension(150,30));
+        
+        //Lay out the demo.
+        jPanel = new JPanel();
+        jPanel.setLayout(new AbsoluteLayout());
+        jPanel.add(text, new AbsoluteConstraints(30,20,170,30));
+        jPanel.add(collectionComboBox, new AbsoluteConstraints(30,60,170,30));
+        jPanel.add(jButton1, new AbsoluteConstraints(30,120,170,30));
+        jPanel.setPreferredSize(new Dimension(225,180));
+        this.setContentPane(jPanel);
+        
+        //Display the window.
+        this.pack();
+        this.setVisible(true);
+    }
+    
+    
+    /** Listens to the combo box. */
+    public void jButton1_actionPerformed(ActionEvent e){ 
+	String collectionName = collectionComboBox.getSelectedItem().toString();
+	this.dispose();
+	MainApplication ma = new MainApplication(collectionName);
+    }
+    
+    /**
+     * Create the GUI and show it.  For thread safety,
+     * this method should be invoked from the
+     * event-dispatching thread.
+     */
+    
+    public static void main(String[] args) {
+        //Schedule a job for the event-dispatching thread:
+        //creating and showing this application's GUI.
+    	collectionChooser cc = new collectionChooser();    	
+    }
+}
+
+class collectionChooser_jButton1_Adapter implements ActionListener {
+    private collectionChooser adaptee;
+    
+    collectionChooser_jButton1_Adapter(collectionChooser adaptee) {
+        this.adaptee = adaptee;
+    }
+    
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButton1_actionPerformed(e);
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/costModel.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/costModel.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/costModel.java	(revision 17184)
@@ -0,0 +1,23 @@
+package org.greenstone3.ms;
+
+public class costModel {
+	double cost = 0;
+	String target ="";
+	
+	public String getString(){
+		return target;
+	}
+	
+	public double getCost(){
+		return cost;
+	}
+	
+	public void setCost(double arg){
+		cost = arg;
+	}
+	
+	public void setString(String arg){
+		target = arg;
+	}
+	
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/metadatatable.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/metadatatable.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/metadatatable.java	(revision 17184)
@@ -0,0 +1,69 @@
+package org.greenstone3.ms;
+
+import java.awt.Toolkit;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import java.awt.Dimension;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2007</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class metadatatable {
+    boolean packFrame = false;
+
+    /**
+     * Construct and show the application.
+     */
+    public metadatatable(String[] dataNames, Object[][] dataset) {
+    	MetadataTableFrame frame = new MetadataTableFrame(dataNames, dataset);
+        // Validate frames that have preset sizes
+        // Pack frames that have useful preferred size info, e.g. from their layout
+        if (packFrame) {
+            frame.pack();
+        } else {
+            frame.validate();
+        }
+
+        // Center the window
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        Dimension frameSize = frame.getSize();
+        if (frameSize.height > screenSize.height) {
+            frameSize.height = screenSize.height;
+        }
+        if (frameSize.width > screenSize.width) {
+            frameSize.width = screenSize.width;
+        }
+        frame.setLocation((screenSize.width - frameSize.width) / 2,
+                          (screenSize.height - frameSize.height) / 2);
+        frame.setVisible(true);
+    }
+
+    /**
+     * Application entry point.
+     *
+     * @param args String[]
+     */
+    public static void main(String[] args) {
+        SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                try {
+                    UIManager.setLookAndFeel(UIManager.
+                                             getSystemLookAndFeelClassName());
+                } catch (Exception exception) {
+                    exception.printStackTrace();
+                }
+
+                new metadatatable(null, null);
+            }
+        });
+    }
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/test.java
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/test.java	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/test.java	(revision 17184)
@@ -0,0 +1,8 @@
+package org.greenstone3.ms;
+
+public class test {
+
+	public static void main(String[] args){
+		System.out.println("hello world");
+	}
+}
Index: /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/svn-commit.tmp
===================================================================
--- /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/svn-commit.tmp	(revision 17184)
+++ /other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/svn-commit.tmp	(revision 17184)
@@ -0,0 +1,4 @@
+
+--This line, and those below, will be ignored--
+
+A    .
