SF Patch #1602185 for bug #1589902 Duplicate [field] checking error [on input-forms.xml]

git-svn-id: http://scm.dspace.org/svn/repo/trunk@1692 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Scott Yeadon
2006-11-27 23:51:16 +00:00
parent 13abadf76e
commit 61e29037c0
2 changed files with 54 additions and 34 deletions

View File

@@ -13,6 +13,7 @@
- Update DIDL license and change coding style to DSpace standard
(Stuart Lewis)
- SF Patch #1602185 for bug #1589902 Duplicate [field] checking error [on input-forms.xml]
- SF Patch #1598323 Support stats from both 1.3 and 1.4
- SF Patch #1594208 for bug #1592984 Date comparisons strip time in org.dspace.harvest.Harvest
- SF Patch #1596113 [dspace]/bin/update-handle-prefix needs to index-all

View File

@@ -52,6 +52,7 @@ import javax.xml.parsers.*;
import org.apache.log4j.Logger;
import org.dspace.content.MetadataSchema;
import org.dspace.core.ConfigurationManager;
import org.dspace.app.webui.servlet.SubmitServlet;
@@ -460,40 +461,58 @@ public class DCInputsReader
*/
private String checkForDups(String formName, HashMap field, Vector pages)
{
int matches = 0;
String err = null;
String elem = (String)field.get("dc-element");
String qual = (String)field.get("dc-qualifier");
for (int i = 0; i < pages.size(); i++)
{
Vector pg = (Vector)pages.get(i);
for (int j = 0; j < pg.size(); j++)
{
HashMap fld = (HashMap)pg.get(j);
if (((String)fld.get("dc-element")).equals(elem))
{
String ql = (String)fld.get("dc-qualifier");
if (qual != null)
{
if ((ql != null) && ql.equals(qual))
{
matches++;
}
}
else if (ql == null)
{
matches++;
}
}
}
}
if (matches > 1)
{
err = "Duplicate field " + elem + "." + qual + " detected in form " + formName;
}
return err;
int matches = 0;
String err = null;
String schema = (String)field.get("dc-schema");
String elem = (String)field.get("dc-element");
String qual = (String)field.get("dc-qualifier");
if ((schema == null) || (schema.equals("")))
{
schema = MetadataSchema.DC_SCHEMA;
}
String schemaTest;
for (int i = 0; i < pages.size(); i++)
{
Vector pg = (Vector)pages.get(i);
for (int j = 0; j < pg.size(); j++)
{
HashMap fld = (HashMap)pg.get(j);
if ((fld.get("dc-schema") == null) ||
(((String)fld.get("dc-schema")).equals("")))
{
schemaTest = MetadataSchema.DC_SCHEMA;
}
else
{
schemaTest = (String)fld.get("dc-schema");
}
// Are the schema and element the same? If so, check the qualifier
if ((((String)fld.get("dc-element")).equals(elem)) &&
(schemaTest.equals(schema)))
{
String ql = (String)fld.get("dc-qualifier");
if (qual != null)
{
if ((ql != null) && ql.equals(qual))
{
matches++;
}
}
else if (ql == null)
{
matches++;
}
}
}
}
if (matches > 1)
{
err = "Duplicate field " + schema + "." + elem + "." + qual + " detected in form " + formName;
}
return err;
}