mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 03:23:13 +00:00
Support Metadata On All DSpaceObjects
This commit is contained in:
@@ -38,7 +38,7 @@ public class DeleteMetadataAction extends UpdateMetadataAction {
|
|||||||
for (String f : targetFields)
|
for (String f : targetFields)
|
||||||
{
|
{
|
||||||
DtoMetadata dummy = DtoMetadata.create(f, Item.ANY, "");
|
DtoMetadata dummy = DtoMetadata.create(f, Item.ANY, "");
|
||||||
DCValue[] ardcv = item.getMetadata(f);
|
DCValue[] ardcv = item.getMetadataByMetadataString(f);
|
||||||
|
|
||||||
ItemUpdate.pr("Metadata to be deleted: ");
|
ItemUpdate.pr("Metadata to be deleted: ");
|
||||||
for (DCValue dcv : ardcv)
|
for (DCValue dcv : ardcv)
|
||||||
|
@@ -35,14 +35,14 @@ public class RequestItemMetadataStrategy extends RequestItemSubmitterStrategy {
|
|||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (emailMetadata != null)
|
if (emailMetadata != null)
|
||||||
{
|
{
|
||||||
DCValue[] vals = item.getMetadata(emailMetadata);
|
DCValue[] vals = item.getMetadataByMetadataString(emailMetadata);
|
||||||
if (vals.length > 0)
|
if (vals.length > 0)
|
||||||
{
|
{
|
||||||
String email = vals[0].value;
|
String email = vals[0].value;
|
||||||
String fullname = null;
|
String fullname = null;
|
||||||
if (fullNameMatadata != null)
|
if (fullNameMatadata != null)
|
||||||
{
|
{
|
||||||
DCValue[] nameVals = item.getMetadata(fullNameMatadata);
|
DCValue[] nameVals = item.getMetadataByMetadataString(fullNameMatadata);
|
||||||
if (nameVals.length > 0)
|
if (nameVals.length > 0)
|
||||||
{
|
{
|
||||||
fullname = nameVals[0].value;
|
fullname = nameVals[0].value;
|
||||||
|
@@ -29,7 +29,7 @@ public class MetadataAuthorityISSNExtractor implements ISSNItemExtractor
|
|||||||
List<String> values = new ArrayList<String>();
|
List<String> values = new ArrayList<String>();
|
||||||
for (String metadata : metadataList)
|
for (String metadata : metadataList)
|
||||||
{
|
{
|
||||||
DCValue[] dcvalues = item.getMetadata(metadata);
|
DCValue[] dcvalues = item.getMetadataByMetadataString(metadata);
|
||||||
for (DCValue dcvalue : dcvalues)
|
for (DCValue dcvalue : dcvalues)
|
||||||
{
|
{
|
||||||
values.add(dcvalue.authority);
|
values.add(dcvalue.authority);
|
||||||
|
@@ -29,7 +29,7 @@ public class MetadataValueISSNExtractor implements ISSNItemExtractor
|
|||||||
List<String> values = new ArrayList<String>();
|
List<String> values = new ArrayList<String>();
|
||||||
for (String metadata : metadataList)
|
for (String metadata : metadataList)
|
||||||
{
|
{
|
||||||
DCValue[] dcvalues = item.getMetadata(metadata);
|
DCValue[] dcvalues = item.getMetadataByMetadataString(metadata);
|
||||||
for (DCValue dcvalue : dcvalues)
|
for (DCValue dcvalue : dcvalues)
|
||||||
{
|
{
|
||||||
values.add(dcvalue.value);
|
values.add(dcvalue.value);
|
||||||
|
@@ -265,7 +265,7 @@ public class SyndicationFeed
|
|||||||
df = df.replaceAll("\\(date\\)", "");
|
df = df.replaceAll("\\(date\\)", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
DCValue dcv[] = item.getMetadata(df);
|
DCValue dcv[] = item.getMetadataByMetadataString(df);
|
||||||
if (dcv.length > 0)
|
if (dcv.length > 0)
|
||||||
{
|
{
|
||||||
String fieldLabel = labels.get(MSG_METADATA + df);
|
String fieldLabel = labels.get(MSG_METADATA + df);
|
||||||
@@ -298,7 +298,7 @@ public class SyndicationFeed
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This gets the authors into an ATOM feed
|
// This gets the authors into an ATOM feed
|
||||||
DCValue authors[] = item.getMetadata(authorField);
|
DCValue authors[] = item.getMetadataByMetadataString(authorField);
|
||||||
if (authors.length > 0)
|
if (authors.length > 0)
|
||||||
{
|
{
|
||||||
List<SyndPerson> creators = new ArrayList<SyndPerson>();
|
List<SyndPerson> creators = new ArrayList<SyndPerson>();
|
||||||
@@ -318,7 +318,7 @@ public class SyndicationFeed
|
|||||||
DCModule dc = new DCModuleImpl();
|
DCModule dc = new DCModuleImpl();
|
||||||
if (dcCreatorField != null)
|
if (dcCreatorField != null)
|
||||||
{
|
{
|
||||||
DCValue dcAuthors[] = item.getMetadata(dcCreatorField);
|
DCValue dcAuthors[] = item.getMetadataByMetadataString(dcCreatorField);
|
||||||
if (dcAuthors.length > 0)
|
if (dcAuthors.length > 0)
|
||||||
{
|
{
|
||||||
List<String> creators = new ArrayList<String>();
|
List<String> creators = new ArrayList<String>();
|
||||||
@@ -331,7 +331,7 @@ public class SyndicationFeed
|
|||||||
}
|
}
|
||||||
if (dcDateField != null && !hasDate)
|
if (dcDateField != null && !hasDate)
|
||||||
{
|
{
|
||||||
DCValue v[] = item.getMetadata(dcDateField);
|
DCValue v[] = item.getMetadataByMetadataString(dcDateField);
|
||||||
if (v.length > 0)
|
if (v.length > 0)
|
||||||
{
|
{
|
||||||
dc.setDate((new DCDate(v[0].value)).toDate());
|
dc.setDate((new DCDate(v[0].value)).toDate());
|
||||||
@@ -339,7 +339,7 @@ public class SyndicationFeed
|
|||||||
}
|
}
|
||||||
if (dcDescriptionField != null)
|
if (dcDescriptionField != null)
|
||||||
{
|
{
|
||||||
DCValue v[] = item.getMetadata(dcDescriptionField);
|
DCValue v[] = item.getMetadataByMetadataString(dcDescriptionField);
|
||||||
if (v.length > 0)
|
if (v.length > 0)
|
||||||
{
|
{
|
||||||
StringBuffer descs = new StringBuffer();
|
StringBuffer descs = new StringBuffer();
|
||||||
@@ -381,7 +381,7 @@ public class SyndicationFeed
|
|||||||
}
|
}
|
||||||
//Also try to add an external value from dc.identifier.other
|
//Also try to add an external value from dc.identifier.other
|
||||||
// We are assuming that if this is set, then it is a media file
|
// We are assuming that if this is set, then it is a media file
|
||||||
DCValue[] externalMedia = item.getMetadata(externalSourceField);
|
DCValue[] externalMedia = item.getMetadataByMetadataString(externalSourceField);
|
||||||
if(externalMedia.length > 0)
|
if(externalMedia.length > 0)
|
||||||
{
|
{
|
||||||
for(int i = 0; i< externalMedia.length; i++)
|
for(int i = 0; i< externalMedia.length; i++)
|
||||||
@@ -567,7 +567,7 @@ public class SyndicationFeed
|
|||||||
// spoonful of syntactic sugar when we only need first value
|
// spoonful of syntactic sugar when we only need first value
|
||||||
private String getOneDC(Item item, String field)
|
private String getOneDC(Item item, String field)
|
||||||
{
|
{
|
||||||
DCValue dcv[] = item.getMetadata(field);
|
DCValue dcv[] = item.getMetadataByMetadataString(field);
|
||||||
return (dcv.length > 0) ? dcv[0].value : null;
|
return (dcv.length > 0) ? dcv[0].value : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,9 +40,6 @@ public class BrowseItem extends DSpaceObject
|
|||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getLogger(BrowseItem.class);
|
private static Logger log = Logger.getLogger(BrowseItem.class);
|
||||||
|
|
||||||
/** DSpace context */
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
/** a List of all the metadata */
|
/** a List of all the metadata */
|
||||||
private List<DCValue> metadata = new ArrayList<DCValue>();
|
private List<DCValue> metadata = new ArrayList<DCValue>();
|
||||||
|
|
||||||
@@ -62,16 +59,15 @@ public class BrowseItem extends DSpaceObject
|
|||||||
private String handle = null;
|
private String handle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new browse item with the given context and the database id
|
* Construct a new browse item with the given ourContext and the database id
|
||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace ourContext
|
||||||
* @param id the database id of the item
|
* @param id the database id of the item
|
||||||
* @param in_archive
|
* @param in_archive
|
||||||
* @param withdrawn
|
* @param withdrawn
|
||||||
*/
|
*/
|
||||||
public BrowseItem(Context context, int id, boolean in_archive, boolean withdrawn, boolean discoverable)
|
public BrowseItem(Context context, int id, boolean in_archive, boolean withdrawn, boolean discoverable) {
|
||||||
{
|
super(context);
|
||||||
this.context = context;
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.in_archive = in_archive;
|
this.in_archive = in_archive;
|
||||||
this.withdrawn = withdrawn;
|
this.withdrawn = withdrawn;
|
||||||
@@ -88,18 +84,20 @@ public class BrowseItem extends DSpaceObject
|
|||||||
* @return array of matching values
|
* @return array of matching values
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public DCValue[] getMetadata(String schema, String element, String qualifier, String lang)
|
public DCValue[] getMetadata(String schema, String element, String qualifier, String lang) {
|
||||||
throws SQLException
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BrowseItemDAO dao = BrowseDAOFactory.getItemInstance(context);
|
BrowseItemDAO dao = BrowseDAOFactory.getItemInstance(ourContext);
|
||||||
|
|
||||||
// if the qualifier is a wildcard, we have to get it out of the
|
// if the qualifier is a wildcard, we have to get it out of the
|
||||||
// database
|
// database
|
||||||
if (Item.ANY.equals(qualifier))
|
if (Item.ANY.equals(qualifier))
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
return dao.queryMetadata(id, schema, element, qualifier, lang);
|
return dao.queryMetadata(id, schema, element, qualifier, lang);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("caught exception: ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metadata.isEmpty())
|
if (!metadata.isEmpty())
|
||||||
@@ -119,7 +117,12 @@ public class BrowseItem extends DSpaceObject
|
|||||||
|
|
||||||
if (values.isEmpty())
|
if (values.isEmpty())
|
||||||
{
|
{
|
||||||
DCValue[] dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
|
DCValue[] dcvs = new DCValue[0];
|
||||||
|
try {
|
||||||
|
dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("caught exception: ", e);
|
||||||
|
}
|
||||||
if (dcvs != null)
|
if (dcvs != null)
|
||||||
{
|
{
|
||||||
Collections.addAll(metadata, dcvs);
|
Collections.addAll(metadata, dcvs);
|
||||||
@@ -135,7 +138,12 @@ public class BrowseItem extends DSpaceObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DCValue[] dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
|
DCValue[] dcvs = new DCValue[0];
|
||||||
|
try {
|
||||||
|
dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("caught exception: ", e);
|
||||||
|
}
|
||||||
if (dcvs != null)
|
if (dcvs != null)
|
||||||
{
|
{
|
||||||
Collections.addAll(metadata, dcvs);
|
Collections.addAll(metadata, dcvs);
|
||||||
@@ -286,7 +294,7 @@ public class BrowseItem extends DSpaceObject
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.handle = HandleManager.findHandle(context, this);
|
this.handle = HandleManager.findHandle(ourContext, this);
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
@@ -310,7 +318,7 @@ public class BrowseItem extends DSpaceObject
|
|||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
// instantiate an item for this one. Not nice.
|
// instantiate an item for this one. Not nice.
|
||||||
Item item = Item.find(context, id);
|
Item item = Item.find(ourContext, id);
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
@@ -353,7 +361,7 @@ public class BrowseItem extends DSpaceObject
|
|||||||
|
|
||||||
if ((original[0].getBitstreams().length > 1) && (original[0].getPrimaryBitstreamID() > -1))
|
if ((original[0].getBitstreams().length > 1) && (original[0].getPrimaryBitstreamID() > -1))
|
||||||
{
|
{
|
||||||
originalBitstream = Bitstream.find(context, original[0].getPrimaryBitstreamID());
|
originalBitstream = Bitstream.find(ourContext, original[0].getPrimaryBitstreamID());
|
||||||
thumbnailBitstream = thumbs[0].getBitstreamByName(originalBitstream.getName() + ".jpg");
|
thumbnailBitstream = thumbs[0].getBitstreamByName(originalBitstream.getName() + ".jpg");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -363,7 +371,7 @@ public class BrowseItem extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((thumbnailBitstream != null)
|
if ((thumbnailBitstream != null)
|
||||||
&& (AuthorizeManager.authorizeActionBoolean(context, thumbnailBitstream, Constants.READ)))
|
&& (AuthorizeManager.authorizeActionBoolean(ourContext, thumbnailBitstream, Constants.READ)))
|
||||||
{
|
{
|
||||||
return new Thumbnail(thumbnailBitstream, originalBitstream);
|
return new Thumbnail(thumbnailBitstream, originalBitstream);
|
||||||
}
|
}
|
||||||
@@ -374,23 +382,12 @@ public class BrowseItem extends DSpaceObject
|
|||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
// FIXME: there is an exception handling problem here
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||||
try
|
|
||||||
{
|
|
||||||
DCValue t[] = getMetadata("dc", "title", null, Item.ANY);
|
|
||||||
return (t.length >= 1) ? t[0].value : null;
|
|
||||||
}
|
|
||||||
catch (SQLException sqle)
|
|
||||||
{
|
|
||||||
log.error("caught exception: ", sqle);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() throws SQLException, AuthorizeException
|
public void update() throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.browse;
|
package org.dspace.browse;
|
||||||
|
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.storage.rdbms.TableRowIterator;
|
import org.dspace.storage.rdbms.TableRowIterator;
|
||||||
import org.dspace.storage.rdbms.DatabaseManager;
|
import org.dspace.storage.rdbms.DatabaseManager;
|
||||||
import org.dspace.storage.rdbms.TableRow;
|
import org.dspace.storage.rdbms.TableRow;
|
||||||
@@ -26,31 +27,34 @@ public class BrowseItemDAOOracle implements BrowseItemDAO
|
|||||||
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
||||||
private String getByMetadataElement = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
private String getByMetadataElement = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||||
|
|
||||||
"WHERE metadatavalue.item_id = ? " +
|
"WHERE metadatavalue.resource_id = ? " +
|
||||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||||
" AND metadatafieldregistry.element = ? " +
|
" AND metadatafieldregistry.element = ? " +
|
||||||
" AND metadatafieldregistry.qualifier IS NULL " +
|
" AND metadatafieldregistry.qualifier IS NULL " +
|
||||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||||
" AND metadataschemaregistry.short_id = ? " +
|
" AND metadataschemaregistry.short_id = ? " +
|
||||||
|
" AND metadatavalue.resource_type_id = ? " +
|
||||||
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
||||||
|
|
||||||
/** query to get the text value of a metadata element and qualifier */
|
/** query to get the text value of a metadata element and qualifier */
|
||||||
private String getByMetadata = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
private String getByMetadata = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||||
"WHERE metadatavalue.item_id = ? " +
|
"WHERE metadatavalue.resource_id = ? " +
|
||||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||||
" AND metadatafieldregistry.element = ? " +
|
" AND metadatafieldregistry.element = ? " +
|
||||||
" AND metadatafieldregistry.qualifier = ? " +
|
" AND metadatafieldregistry.qualifier = ? " +
|
||||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||||
" AND metadataschemaregistry.short_id = ? " +
|
" AND metadataschemaregistry.short_id = ? " +
|
||||||
|
" AND metadatavalue.resource_type_id = ? " +
|
||||||
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
||||||
|
|
||||||
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
||||||
private String getByMetadataAnyQualifier = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
private String getByMetadataAnyQualifier = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||||
"WHERE metadatavalue.item_id = ? " +
|
"WHERE metadatavalue.resource_id = ? " +
|
||||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||||
" AND metadatafieldregistry.element = ? " +
|
" AND metadatafieldregistry.element = ? " +
|
||||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||||
" AND metadataschemaregistry.short_id = ? " +
|
" AND metadataschemaregistry.short_id = ? " +
|
||||||
|
" AND metadatavalue.resource_type_id = ? " +
|
||||||
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
||||||
|
|
||||||
/** DSpace context */
|
/** DSpace context */
|
||||||
@@ -101,17 +105,17 @@ public class BrowseItemDAOOracle implements BrowseItemDAO
|
|||||||
{
|
{
|
||||||
if (qualifier == null)
|
if (qualifier == null)
|
||||||
{
|
{
|
||||||
Object[] params = { Integer.valueOf(itemId), element, schema };
|
Object[] params = { Integer.valueOf(itemId), element, schema, Constants.ITEM };
|
||||||
tri = DatabaseManager.query(context, getByMetadataElement, params);
|
tri = DatabaseManager.query(context, getByMetadataElement, params);
|
||||||
}
|
}
|
||||||
else if (Item.ANY.equals(qualifier))
|
else if (Item.ANY.equals(qualifier))
|
||||||
{
|
{
|
||||||
Object[] params = { Integer.valueOf(itemId), element, schema };
|
Object[] params = { Integer.valueOf(itemId), element, schema, Constants.ITEM };
|
||||||
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
|
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Object[] params = { Integer.valueOf(itemId), element, qualifier, schema };
|
Object[] params = { Integer.valueOf(itemId), element, qualifier, schema, Constants.ITEM };
|
||||||
tri = DatabaseManager.query(context, getByMetadata, params);
|
tri = DatabaseManager.query(context, getByMetadata, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.browse;
|
package org.dspace.browse;
|
||||||
|
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.storage.rdbms.TableRowIterator;
|
import org.dspace.storage.rdbms.TableRowIterator;
|
||||||
import org.dspace.storage.rdbms.DatabaseManager;
|
import org.dspace.storage.rdbms.DatabaseManager;
|
||||||
import org.dspace.storage.rdbms.TableRow;
|
import org.dspace.storage.rdbms.TableRow;
|
||||||
@@ -25,31 +26,34 @@ public class BrowseItemDAOPostgres implements BrowseItemDAO
|
|||||||
|
|
||||||
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
||||||
private String getByMetadataElement = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
private String getByMetadataElement = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||||
"WHERE metadatavalue.item_id = ? " +
|
"WHERE metadatavalue.resource_id = ? " +
|
||||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||||
" AND metadatafieldregistry.element = ? " +
|
" AND metadatafieldregistry.element = ? " +
|
||||||
" AND metadatafieldregistry.qualifier IS NULL " +
|
" AND metadatafieldregistry.qualifier IS NULL " +
|
||||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||||
" AND metadataschemaregistry.short_id = ? " +
|
" AND metadataschemaregistry.short_id = ? " +
|
||||||
|
" AND metadatavalue.resource_type_id = ? " +
|
||||||
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
||||||
|
|
||||||
/** query to get the text value of a metadata element and qualifier */
|
/** query to get the text value of a metadata element and qualifier */
|
||||||
private String getByMetadata = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
private String getByMetadata = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||||
"WHERE metadatavalue.item_id = ? " +
|
"WHERE metadatavalue.resource_id = ? " +
|
||||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||||
" AND metadatafieldregistry.element = ? " +
|
" AND metadatafieldregistry.element = ? " +
|
||||||
" AND metadatafieldregistry.qualifier = ? " +
|
" AND metadatafieldregistry.qualifier = ? " +
|
||||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||||
" AND metadataschemaregistry.short_id = ? " +
|
" AND metadataschemaregistry.short_id = ? " +
|
||||||
|
" AND metadatavalue.resource_type_id = ? " +
|
||||||
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
||||||
|
|
||||||
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
||||||
private String getByMetadataAnyQualifier = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
private String getByMetadataAnyQualifier = "SELECT authority, confidence, text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||||
"WHERE metadatavalue.item_id = ? " +
|
"WHERE metadatavalue.resource_id = ? " +
|
||||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||||
" AND metadatafieldregistry.element = ? " +
|
" AND metadatafieldregistry.element = ? " +
|
||||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||||
" AND metadataschemaregistry.short_id = ? " +
|
" AND metadataschemaregistry.short_id = ? " +
|
||||||
|
" AND metadatavalue.resource_type_id = ? " +
|
||||||
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
" ORDER BY metadatavalue.metadata_field_id, metadatavalue.place";
|
||||||
|
|
||||||
/** DSpace context */
|
/** DSpace context */
|
||||||
@@ -101,16 +105,16 @@ public class BrowseItemDAOPostgres implements BrowseItemDAO
|
|||||||
if (qualifier == null)
|
if (qualifier == null)
|
||||||
{
|
{
|
||||||
Object[] params = { Integer.valueOf(itemId), element, schema };
|
Object[] params = { Integer.valueOf(itemId), element, schema };
|
||||||
tri = DatabaseManager.query(context, getByMetadataElement, params);
|
tri = DatabaseManager.query(context, getByMetadataElement, params, Constants.ITEM);
|
||||||
}
|
}
|
||||||
else if (Item.ANY.equals(qualifier))
|
else if (Item.ANY.equals(qualifier))
|
||||||
{
|
{
|
||||||
Object[] params = { Integer.valueOf(itemId), element, schema };
|
Object[] params = { Integer.valueOf(itemId), element, schema };
|
||||||
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
|
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params, Constants.ITEM);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Object[] params = { Integer.valueOf(itemId), element, qualifier, schema };
|
Object[] params = { Integer.valueOf(itemId), element, qualifier, schema, Constants.ITEM };
|
||||||
tri = DatabaseManager.query(context, getByMetadata, params);
|
tri = DatabaseManager.query(context, getByMetadata, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -330,7 +330,7 @@ public class SolrBrowseCreateDAO implements BrowseCreateDAO,
|
|||||||
{
|
{
|
||||||
for (SortOption so : SortOption.getSortOptions())
|
for (SortOption so : SortOption.getSortOptions())
|
||||||
{
|
{
|
||||||
DCValue[] dcvalue = item.getMetadata(so.getMetadata());
|
DCValue[] dcvalue = item.getMetadataByMetadataString(so.getMetadata());
|
||||||
if (dcvalue != null && dcvalue.length > 0)
|
if (dcvalue != null && dcvalue.length > 0)
|
||||||
{
|
{
|
||||||
String nValue = OrderFormat
|
String nValue = OrderFormat
|
||||||
|
@@ -41,8 +41,6 @@ public class Bitstream extends DSpaceObject
|
|||||||
/** log4j logger */
|
/** log4j logger */
|
||||||
private static Logger log = Logger.getLogger(Bitstream.class);
|
private static Logger log = Logger.getLogger(Bitstream.class);
|
||||||
|
|
||||||
/** Our context */
|
|
||||||
private Context bContext;
|
|
||||||
|
|
||||||
/** The row in the table representing this bitstream */
|
/** The row in the table representing this bitstream */
|
||||||
private TableRow bRow;
|
private TableRow bRow;
|
||||||
@@ -53,9 +51,6 @@ public class Bitstream extends DSpaceObject
|
|||||||
/** Flag set when data is modified, for events */
|
/** Flag set when data is modified, for events */
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
/** Flag set when metadata is modified, for events */
|
|
||||||
private boolean modifiedMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor for creating a Bitstream object based on the contents
|
* Private constructor for creating a Bitstream object based on the contents
|
||||||
* of a DB table row.
|
* of a DB table row.
|
||||||
@@ -68,7 +63,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
Bitstream(Context context, TableRow row) throws SQLException
|
Bitstream(Context context, TableRow row) throws SQLException
|
||||||
{
|
{
|
||||||
bContext = context;
|
super(context);
|
||||||
bRow = row;
|
bRow = row;
|
||||||
|
|
||||||
// Get the bitstream format
|
// Get the bitstream format
|
||||||
@@ -91,7 +86,6 @@ public class Bitstream extends DSpaceObject
|
|||||||
context.cache(this, row.getIntColumn("bitstream_id"));
|
context.cache(this, row.getIntColumn("bitstream_id"));
|
||||||
|
|
||||||
modified = false;
|
modified = false;
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,9 +292,8 @@ public class Bitstream extends DSpaceObject
|
|||||||
*
|
*
|
||||||
* @return the name of the bitstream
|
* @return the name of the bitstream
|
||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName(){
|
||||||
{
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||||
return bRow.getStringColumn("name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -309,11 +302,8 @@ public class Bitstream extends DSpaceObject
|
|||||||
* @param n
|
* @param n
|
||||||
* the new name of the bitstream
|
* the new name of the bitstream
|
||||||
*/
|
*/
|
||||||
public void setName(String n)
|
public void setName(String n) {
|
||||||
{
|
setMetadataSingleValue(MetadataSchema.DC_SCHEMA, "title", null, null, n);
|
||||||
bRow.setColumn("name", n);
|
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails("Name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +315,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getSource()
|
public String getSource()
|
||||||
{
|
{
|
||||||
return bRow.getStringColumn("source");
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "source", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -334,11 +324,8 @@ public class Bitstream extends DSpaceObject
|
|||||||
* @param n
|
* @param n
|
||||||
* the new source of the bitstream
|
* the new source of the bitstream
|
||||||
*/
|
*/
|
||||||
public void setSource(String n)
|
public void setSource(String n) {
|
||||||
{
|
setMetadataSingleValue(MetadataSchema.DC_SCHEMA, "source", null, null, n);
|
||||||
bRow.setColumn("source", n);
|
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails("Source");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,7 +336,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return bRow.getStringColumn("description");
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "description", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,11 +345,8 @@ public class Bitstream extends DSpaceObject
|
|||||||
* @param n
|
* @param n
|
||||||
* the new description of the bitstream
|
* the new description of the bitstream
|
||||||
*/
|
*/
|
||||||
public void setDescription(String n)
|
public void setDescription(String n) {
|
||||||
{
|
setMetadataSingleValue(MetadataSchema.DC_SCHEMA, "description", null, null, n);
|
||||||
bRow.setColumn("description", n);
|
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails("Description");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -403,14 +387,9 @@ public class Bitstream extends DSpaceObject
|
|||||||
* the user's description of the format
|
* the user's description of the format
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void setUserFormatDescription(String desc) throws SQLException
|
public void setUserFormatDescription(String desc) throws SQLException {
|
||||||
{
|
|
||||||
// FIXME: Would be better if this didn't throw an SQLException,
|
|
||||||
// but we need to find the unknown format!
|
|
||||||
setFormat(null);
|
setFormat(null);
|
||||||
bRow.setColumn("user_format_description", desc);
|
setMetadataSingleValue(MetadataSchema.DC_SCHEMA, "format", null, null, desc);
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails("UserFormatDescription");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -421,7 +400,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getUserFormatDescription()
|
public String getUserFormatDescription()
|
||||||
{
|
{
|
||||||
return bRow.getStringColumn("user_format_description");
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "format", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -435,7 +414,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
if (bitstreamFormat.getShortDescription().equals("Unknown"))
|
if (bitstreamFormat.getShortDescription().equals("Unknown"))
|
||||||
{
|
{
|
||||||
// Get user description if there is one
|
// Get user description if there is one
|
||||||
String desc = bRow.getStringColumn("user_format_description");
|
String desc = getUserFormatDescription();
|
||||||
|
|
||||||
if (desc == null)
|
if (desc == null)
|
||||||
{
|
{
|
||||||
@@ -476,7 +455,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
if (f == null)
|
if (f == null)
|
||||||
{
|
{
|
||||||
// Use "Unknown" format
|
// Use "Unknown" format
|
||||||
bitstreamFormat = BitstreamFormat.findUnknown(bContext);
|
bitstreamFormat = BitstreamFormat.findUnknown(ourContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -484,7 +463,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove user type description
|
// Remove user type description
|
||||||
bRow.setColumnNull("user_format_description");
|
clearMetadata(MetadataSchema.DC_SCHEMA,"format",null, Item.ANY);
|
||||||
|
|
||||||
// Update the ID in the table row
|
// Update the ID in the table row
|
||||||
bRow.setColumn("bitstream_format_id", bitstreamFormat.getID());
|
bRow.setColumn("bitstream_format_id", bitstreamFormat.getID());
|
||||||
@@ -501,27 +480,24 @@ public class Bitstream extends DSpaceObject
|
|||||||
public void update() throws SQLException, AuthorizeException
|
public void update() throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
// Check authorisation
|
// Check authorisation
|
||||||
AuthorizeManager.authorizeAction(bContext, this, Constants.WRITE);
|
AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
|
||||||
|
|
||||||
log.info(LogManager.getHeader(bContext, "update_bitstream",
|
log.info(LogManager.getHeader(ourContext, "update_bitstream",
|
||||||
"bitstream_id=" + getID()));
|
"bitstream_id=" + getID()));
|
||||||
|
|
||||||
|
DatabaseManager.update(ourContext, bRow);
|
||||||
|
|
||||||
if (modified)
|
if (modified)
|
||||||
{
|
{
|
||||||
bContext.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM,
|
ourContext.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM, getID(), null, getIdentifiers(ourContext)));
|
||||||
getID(), null, getIdentifiers(bContext)));
|
|
||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
if (modifiedMetadata)
|
if (modifiedMetadata)
|
||||||
{
|
{
|
||||||
bContext.addEvent(new Event(Event.MODIFY_METADATA,
|
updateMetadata();
|
||||||
Constants.BITSTREAM, getID(), getDetails(),
|
|
||||||
getIdentifiers(bContext)));
|
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseManager.update(bContext, bRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -535,28 +511,30 @@ public class Bitstream extends DSpaceObject
|
|||||||
|
|
||||||
// changed to a check on remove
|
// changed to a check on remove
|
||||||
// Check authorisation
|
// Check authorisation
|
||||||
//AuthorizeManager.authorizeAction(bContext, this, Constants.DELETE);
|
//AuthorizeManager.authorizeAction(ourContext, this, Constants.DELETE);
|
||||||
log.info(LogManager.getHeader(bContext, "delete_bitstream",
|
log.info(LogManager.getHeader(ourContext, "delete_bitstream",
|
||||||
"bitstream_id=" + getID()));
|
"bitstream_id=" + getID()));
|
||||||
|
|
||||||
bContext.addEvent(new Event(Event.DELETE, Constants.BITSTREAM, getID(),
|
ourContext.addEvent(new Event(Event.DELETE, Constants.BITSTREAM, getID(),
|
||||||
String.valueOf(getSequenceID()), getIdentifiers(bContext)));
|
String.valueOf(getSequenceID()), getIdentifiers(ourContext)));
|
||||||
|
|
||||||
// Remove from cache
|
// Remove from cache
|
||||||
bContext.removeCached(this, getID());
|
ourContext.removeCached(this, getID());
|
||||||
|
|
||||||
// Remove policies
|
// Remove policies
|
||||||
AuthorizeManager.removeAllPolicies(bContext, this);
|
AuthorizeManager.removeAllPolicies(ourContext, this);
|
||||||
|
|
||||||
// Remove references to primary bitstreams in bundle
|
// Remove references to primary bitstreams in bundle
|
||||||
String query = "update bundle set primary_bitstream_id = ";
|
String query = "update bundle set primary_bitstream_id = ";
|
||||||
query += (oracle ? "''" : "Null") + " where primary_bitstream_id = ? ";
|
query += (oracle ? "''" : "Null") + " where primary_bitstream_id = ? ";
|
||||||
DatabaseManager.updateQuery(bContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
query, bRow.getIntColumn("bitstream_id"));
|
query, bRow.getIntColumn("bitstream_id"));
|
||||||
|
|
||||||
// Remove bitstream itself
|
// Remove bitstream itself
|
||||||
BitstreamStorageManager.delete(bContext, bRow
|
BitstreamStorageManager.delete(ourContext, bRow
|
||||||
.getIntColumn("bitstream_id"));
|
.getIntColumn("bitstream_id"));
|
||||||
|
|
||||||
|
removeMetadataFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -568,7 +546,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
boolean isDeleted() throws SQLException
|
boolean isDeleted() throws SQLException
|
||||||
{
|
{
|
||||||
String query = "select count(*) as mycount from Bitstream where deleted = '1' and bitstream_id = ? ";
|
String query = "select count(*) as mycount from Bitstream where deleted = '1' and bitstream_id = ? ";
|
||||||
TableRowIterator tri = DatabaseManager.query(bContext, query, bRow.getIntColumn("bitstream_id"));
|
TableRowIterator tri = DatabaseManager.query(ourContext, query, bRow.getIntColumn("bitstream_id"));
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -600,9 +578,9 @@ public class Bitstream extends DSpaceObject
|
|||||||
AuthorizeException
|
AuthorizeException
|
||||||
{
|
{
|
||||||
// Maybe should return AuthorizeException??
|
// Maybe should return AuthorizeException??
|
||||||
AuthorizeManager.authorizeAction(bContext, this, Constants.READ);
|
AuthorizeManager.authorizeAction(ourContext, this, Constants.READ);
|
||||||
|
|
||||||
return BitstreamStorageManager.retrieve(bContext, bRow
|
return BitstreamStorageManager.retrieve(ourContext, bRow
|
||||||
.getIntColumn("bitstream_id"));
|
.getIntColumn("bitstream_id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +593,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
public Bundle[] getBundles() throws SQLException
|
public Bundle[] getBundles() throws SQLException
|
||||||
{
|
{
|
||||||
// Get the bundle table rows
|
// Get the bundle table rows
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(bContext, "bundle",
|
TableRowIterator tri = DatabaseManager.queryTable(ourContext, "bundle",
|
||||||
"SELECT bundle.* FROM bundle, bundle2bitstream WHERE " +
|
"SELECT bundle.* FROM bundle, bundle2bitstream WHERE " +
|
||||||
"bundle.bundle_id=bundle2bitstream.bundle_id AND " +
|
"bundle.bundle_id=bundle2bitstream.bundle_id AND " +
|
||||||
"bundle2bitstream.bitstream_id= ? ",
|
"bundle2bitstream.bitstream_id= ? ",
|
||||||
@@ -630,7 +608,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
TableRow r = tri.next();
|
TableRow r = tri.next();
|
||||||
|
|
||||||
// First check the cache
|
// First check the cache
|
||||||
Bundle fromCache = (Bundle) bContext.fromCache(Bundle.class, r
|
Bundle fromCache = (Bundle) ourContext.fromCache(Bundle.class, r
|
||||||
.getIntColumn("bundle_id"));
|
.getIntColumn("bundle_id"));
|
||||||
|
|
||||||
if (fromCache != null)
|
if (fromCache != null)
|
||||||
@@ -639,7 +617,7 @@ public class Bitstream extends DSpaceObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bundles.add(new Bundle(bContext, r));
|
bundles.add(new Bundle(ourContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -716,23 +694,23 @@ public class Bitstream extends DSpaceObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// is the bitstream a logo for a community or a collection?
|
// is the bitstream a logo for a community or a collection?
|
||||||
TableRow qResult = DatabaseManager.querySingle(bContext,
|
TableRow qResult = DatabaseManager.querySingle(ourContext,
|
||||||
"SELECT collection_id FROM collection " +
|
"SELECT collection_id FROM collection " +
|
||||||
"WHERE logo_bitstream_id = ?",getID());
|
"WHERE logo_bitstream_id = ?",getID());
|
||||||
if (qResult != null)
|
if (qResult != null)
|
||||||
{
|
{
|
||||||
return Collection.find(bContext,qResult.getIntColumn("collection_id"));
|
return Collection.find(ourContext,qResult.getIntColumn("collection_id"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// is the bitstream related to a community?
|
// is the bitstream related to a community?
|
||||||
qResult = DatabaseManager.querySingle(bContext,
|
qResult = DatabaseManager.querySingle(ourContext,
|
||||||
"SELECT community_id FROM community " +
|
"SELECT community_id FROM community " +
|
||||||
"WHERE logo_bitstream_id = ?",getID());
|
"WHERE logo_bitstream_id = ?",getID());
|
||||||
|
|
||||||
if (qResult != null)
|
if (qResult != null)
|
||||||
{
|
{
|
||||||
return Community.find(bContext,qResult.getIntColumn("community_id"));
|
return Community.find(ourContext,qResult.getIntColumn("community_id"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -746,7 +724,6 @@ public class Bitstream extends DSpaceObject
|
|||||||
public void updateLastModified()
|
public void updateLastModified()
|
||||||
{
|
{
|
||||||
//Also fire a modified event since the bitstream HAS been modified
|
//Also fire a modified event since the bitstream HAS been modified
|
||||||
bContext.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM, getID(),
|
ourContext.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM, getID(), null, getIdentifiers(ourContext)));
|
||||||
null, getIdentifiers(bContext)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -42,9 +42,6 @@ public class Bundle extends DSpaceObject
|
|||||||
/** log4j logger */
|
/** log4j logger */
|
||||||
private static Logger log = Logger.getLogger(Bundle.class);
|
private static Logger log = Logger.getLogger(Bundle.class);
|
||||||
|
|
||||||
/** Our context */
|
|
||||||
private Context ourContext;
|
|
||||||
|
|
||||||
/** The table row corresponding to this bundle */
|
/** The table row corresponding to this bundle */
|
||||||
private TableRow bundleRow;
|
private TableRow bundleRow;
|
||||||
|
|
||||||
@@ -54,9 +51,6 @@ public class Bundle extends DSpaceObject
|
|||||||
/** Flag set when data is modified, for events */
|
/** Flag set when data is modified, for events */
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
/** Flag set when metadata is modified, for events */
|
|
||||||
private boolean modifiedMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a bundle object with the given table row
|
* Construct a bundle object with the given table row
|
||||||
*
|
*
|
||||||
@@ -67,7 +61,7 @@ public class Bundle extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
Bundle(Context context, TableRow row) throws SQLException
|
Bundle(Context context, TableRow row) throws SQLException
|
||||||
{
|
{
|
||||||
ourContext = context;
|
super(context);
|
||||||
bundleRow = row;
|
bundleRow = row;
|
||||||
bitstreams = new ArrayList<Bitstream>();
|
bitstreams = new ArrayList<Bitstream>();
|
||||||
String bitstreamOrderingField = ConfigurationManager.getProperty("webui.bitstream.order.field");
|
String bitstreamOrderingField = ConfigurationManager.getProperty("webui.bitstream.order.field");
|
||||||
@@ -134,7 +128,6 @@ public class Bundle extends DSpaceObject
|
|||||||
context.cache(this, row.getIntColumn("bundle_id"));
|
context.cache(this, row.getIntColumn("bundle_id"));
|
||||||
|
|
||||||
modified = false;
|
modified = false;
|
||||||
modifiedMetadata = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,7 +219,7 @@ public class Bundle extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return bundleRow.getStringColumn("name");
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,8 +231,7 @@ public class Bundle extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
bundleRow.setColumn("name", name);
|
setMetadataSingleValue(MetadataSchema.DC_SCHEMA, "title", null, null, name);
|
||||||
modifiedMetadata = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -611,6 +603,8 @@ public class Bundle extends DSpaceObject
|
|||||||
log.info(LogManager.getHeader(ourContext, "update_bundle", "bundle_id="
|
log.info(LogManager.getHeader(ourContext, "update_bundle", "bundle_id="
|
||||||
+ getID()));
|
+ getID()));
|
||||||
|
|
||||||
|
DatabaseManager.update(ourContext, bundleRow);
|
||||||
|
|
||||||
if (modified)
|
if (modified)
|
||||||
{
|
{
|
||||||
ourContext.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, getID(),
|
ourContext.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, getID(),
|
||||||
@@ -619,12 +613,9 @@ public class Bundle extends DSpaceObject
|
|||||||
}
|
}
|
||||||
if (modifiedMetadata)
|
if (modifiedMetadata)
|
||||||
{
|
{
|
||||||
ourContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.BUNDLE,
|
updateMetadata();
|
||||||
getID(), null, getIdentifiers(ourContext)));
|
clearDetails();
|
||||||
modifiedMetadata = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseManager.update(ourContext, bundleRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -656,6 +647,8 @@ public class Bundle extends DSpaceObject
|
|||||||
|
|
||||||
// Remove ourself
|
// Remove ourself
|
||||||
DatabaseManager.delete(ourContext, bundleRow);
|
DatabaseManager.delete(ourContext, bundleRow);
|
||||||
|
|
||||||
|
removeMetadataFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -57,9 +57,6 @@ public class Collection extends DSpaceObject
|
|||||||
/** log4j category */
|
/** log4j category */
|
||||||
private static Logger log = Logger.getLogger(Collection.class);
|
private static Logger log = Logger.getLogger(Collection.class);
|
||||||
|
|
||||||
/** Our context */
|
|
||||||
private Context ourContext;
|
|
||||||
|
|
||||||
/** The table row corresponding to this item */
|
/** The table row corresponding to this item */
|
||||||
private TableRow collectionRow;
|
private TableRow collectionRow;
|
||||||
|
|
||||||
@@ -75,9 +72,6 @@ public class Collection extends DSpaceObject
|
|||||||
/** Flag set when data is modified, for events */
|
/** Flag set when data is modified, for events */
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
/** Flag set when metadata is modified, for events */
|
|
||||||
private boolean modifiedMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Groups corresponding to workflow steps - NOTE these start from one, so
|
* Groups corresponding to workflow steps - NOTE these start from one, so
|
||||||
* workflowGroups[0] corresponds to workflow_step_1.
|
* workflowGroups[0] corresponds to workflow_step_1.
|
||||||
@@ -108,7 +102,7 @@ public class Collection extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
Collection(Context context, TableRow row) throws SQLException
|
Collection(Context context, TableRow row) throws SQLException
|
||||||
{
|
{
|
||||||
ourContext = context;
|
super(context);
|
||||||
collectionRow = row;
|
collectionRow = row;
|
||||||
|
|
||||||
// Get the logo bitstream
|
// Get the logo bitstream
|
||||||
@@ -150,7 +144,6 @@ public class Collection extends DSpaceObject
|
|||||||
context.cache(this, row.getIntColumn("collection_id"));
|
context.cache(this, row.getIntColumn("collection_id"));
|
||||||
|
|
||||||
modified = false;
|
modified = false;
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,10 +292,26 @@ public class Collection extends DSpaceObject
|
|||||||
* @return the collections in the system
|
* @return the collections in the system
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static Collection[] findAll(Context context) throws SQLException
|
public static Collection[] findAll(Context context) throws SQLException {
|
||||||
{
|
TableRowIterator tri = null;
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "collection",
|
try {
|
||||||
"SELECT * FROM collection ORDER BY name");
|
String query = "SELECT c.* FROM collection c " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = c.collection_id and m.resource_type_id = ? and m.metadata_field_id = ?) ";
|
||||||
|
if(DatabaseManager.isOracle()){
|
||||||
|
query += " ORDER BY cast(m.text_value as varchar2(128))";
|
||||||
|
}else{
|
||||||
|
query += " ORDER BY m.text_value";
|
||||||
|
}
|
||||||
|
|
||||||
|
tri = DatabaseManager.query(context,
|
||||||
|
query,
|
||||||
|
Constants.COLLECTION,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID()
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Find all Collections - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
List<Collection> collections = new ArrayList<Collection>();
|
List<Collection> collections = new ArrayList<Collection>();
|
||||||
|
|
||||||
@@ -351,9 +360,28 @@ public class Collection extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public static Collection[] findAll(Context context, Integer limit, Integer offset) throws SQLException
|
public static Collection[] findAll(Context context, Integer limit, Integer offset) throws SQLException
|
||||||
{
|
{
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "collection",
|
TableRowIterator tri = null;
|
||||||
"SELECT * FROM collection ORDER BY name limit ? offset ?", limit, offset);
|
try{
|
||||||
|
String query = "SELECT c.* FROM collection c " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = c.collection_id and m.resource_type_id = ? and m.metadata_field_id = ?) ";
|
||||||
|
|
||||||
|
if(DatabaseManager.isOracle()){
|
||||||
|
query += " ORDER BY cast(m.text_value as varchar2(128))";
|
||||||
|
}else{
|
||||||
|
query += " ORDER BY m.text_value";
|
||||||
|
}
|
||||||
|
query += " limit ? offset ?";
|
||||||
|
tri = DatabaseManager.query(context,
|
||||||
|
query,
|
||||||
|
Constants.COLLECTION,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID(),
|
||||||
|
limit,
|
||||||
|
offset
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Find all Collections offset/limit - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
List<Collection> collections = new ArrayList<Collection>();
|
List<Collection> collections = new ArrayList<Collection>();
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -486,10 +514,12 @@ public class Collection extends DSpaceObject
|
|||||||
* @exception IllegalArgumentException
|
* @exception IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getMetadata(String field)
|
public String getMetadata(String field)
|
||||||
{
|
{
|
||||||
String metadata = collectionRow.getStringColumn(field);
|
String[] MDValue = getMDValueByLegacyField(field);
|
||||||
return (metadata == null) ? "" : metadata;
|
String value = getMetadataFirstValue(MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||||
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -504,10 +534,9 @@ public class Collection extends DSpaceObject
|
|||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
* @exception MissingResourceException
|
* @exception MissingResourceException
|
||||||
*/
|
*/
|
||||||
public void setMetadata(String field, String value) throws MissingResourceException
|
@Deprecated
|
||||||
{
|
public void setMetadata(String field, String value) throws MissingResourceException {
|
||||||
if ((field.trim()).equals("name")
|
if ((field.trim()).equals("name") && (value == null || value.trim().equals("")))
|
||||||
&& (value == null || value.trim().equals("")))
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -519,6 +548,8 @@ public class Collection extends DSpaceObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] MDValue = getMDValueByLegacyField(field);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set metadata field to null if null
|
* Set metadata field to null if null
|
||||||
* and trim strings to eliminate excess
|
* and trim strings to eliminate excess
|
||||||
@@ -526,20 +557,21 @@ public class Collection extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
if(value == null)
|
if(value == null)
|
||||||
{
|
{
|
||||||
collectionRow.setColumnNull(field);
|
clearMetadata(MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||||
|
modifiedMetadata = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
collectionRow.setColumn(field, value.trim());
|
setMetadataSingleValue(MDValue[0], MDValue[1], MDValue[2], null, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails(field);
|
addDetails(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return getMetadata("name");
|
String value = getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||||
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -893,8 +925,7 @@ public class Collection extends DSpaceObject
|
|||||||
* @param license
|
* @param license
|
||||||
* the license, or <code>null</code>
|
* the license, or <code>null</code>
|
||||||
*/
|
*/
|
||||||
public void setLicense(String license)
|
public void setLicense(String license) {
|
||||||
{
|
|
||||||
setMetadata("license",license);
|
setMetadata("license",license);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1072,10 +1103,7 @@ public class Collection extends DSpaceObject
|
|||||||
}
|
}
|
||||||
if (modifiedMetadata)
|
if (modifiedMetadata)
|
||||||
{
|
{
|
||||||
ourContext.addEvent(new Event(Event.MODIFY_METADATA,
|
updateMetadata();
|
||||||
Constants.COLLECTION, getID(), getDetails(),
|
|
||||||
getIdentifiers(ourContext)));
|
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1306,6 +1334,8 @@ public class Collection extends DSpaceObject
|
|||||||
{
|
{
|
||||||
g.delete();
|
g.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeMetadataFromDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,10 +16,7 @@ import org.dspace.authorize.AuthorizeManager;
|
|||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.browse.ItemCountException;
|
import org.dspace.browse.ItemCountException;
|
||||||
import org.dspace.browse.ItemCounter;
|
import org.dspace.browse.ItemCounter;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.*;
|
||||||
import org.dspace.core.Context;
|
|
||||||
import org.dspace.core.I18nUtil;
|
|
||||||
import org.dspace.core.LogManager;
|
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.event.Event;
|
import org.dspace.event.Event;
|
||||||
import org.dspace.handle.HandleManager;
|
import org.dspace.handle.HandleManager;
|
||||||
@@ -30,9 +27,7 @@ import org.dspace.storage.rdbms.TableRowIterator;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.MissingResourceException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a community
|
* Class representing a community
|
||||||
@@ -49,9 +44,6 @@ public class Community extends DSpaceObject
|
|||||||
/** log4j category */
|
/** log4j category */
|
||||||
private static Logger log = Logger.getLogger(Community.class);
|
private static Logger log = Logger.getLogger(Community.class);
|
||||||
|
|
||||||
/** Our context */
|
|
||||||
private Context ourContext;
|
|
||||||
|
|
||||||
/** The table row corresponding to this item */
|
/** The table row corresponding to this item */
|
||||||
private TableRow communityRow;
|
private TableRow communityRow;
|
||||||
|
|
||||||
@@ -64,9 +56,6 @@ public class Community extends DSpaceObject
|
|||||||
/** Flag set when data is modified, for events */
|
/** Flag set when data is modified, for events */
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
/** Flag set when metadata is modified, for events */
|
|
||||||
private boolean modifiedMetadata;
|
|
||||||
|
|
||||||
/** The default group of administrators */
|
/** The default group of administrators */
|
||||||
private Group admins;
|
private Group admins;
|
||||||
|
|
||||||
@@ -86,7 +75,7 @@ public class Community extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
Community(Context context, TableRow row) throws SQLException
|
Community(Context context, TableRow row) throws SQLException
|
||||||
{
|
{
|
||||||
ourContext = context;
|
super(context);
|
||||||
communityRow = row;
|
communityRow = row;
|
||||||
|
|
||||||
// Get the logo bitstream
|
// Get the logo bitstream
|
||||||
@@ -107,7 +96,6 @@ public class Community extends DSpaceObject
|
|||||||
context.cache(this, row.getIntColumn("community_id"));
|
context.cache(this, row.getIntColumn("community_id"));
|
||||||
|
|
||||||
modified = false;
|
modified = false;
|
||||||
modifiedMetadata = false;
|
|
||||||
|
|
||||||
admins = groupFromColumn("admin");
|
admins = groupFromColumn("admin");
|
||||||
|
|
||||||
@@ -261,8 +249,25 @@ public class Community extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public static Community[] findAll(Context context) throws SQLException
|
public static Community[] findAll(Context context) throws SQLException
|
||||||
{
|
{
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "community",
|
TableRowIterator tri = null;
|
||||||
"SELECT * FROM community ORDER BY name");
|
try {
|
||||||
|
String query = "SELECT c.* FROM community c " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = c.community_id and m.resource_type_id = ? and m.metadata_field_id = ?) ";
|
||||||
|
if(DatabaseManager.isOracle()){
|
||||||
|
query += " ORDER BY cast(m.text_value as varchar2(128))";
|
||||||
|
}else{
|
||||||
|
query += " ORDER BY m.text_value";
|
||||||
|
}
|
||||||
|
|
||||||
|
tri = DatabaseManager.query(context,
|
||||||
|
query,
|
||||||
|
Constants.COMMUNITY,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID()
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Find all Communities - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
List<Community> communities = new ArrayList<Community>();
|
List<Community> communities = new ArrayList<Community>();
|
||||||
|
|
||||||
@@ -314,10 +319,25 @@ public class Community extends DSpaceObject
|
|||||||
public static Community[] findAllTop(Context context) throws SQLException
|
public static Community[] findAllTop(Context context) throws SQLException
|
||||||
{
|
{
|
||||||
// get all communities that are not children
|
// get all communities that are not children
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "community",
|
TableRowIterator tri = null;
|
||||||
"SELECT * FROM community WHERE NOT community_id IN "
|
try {
|
||||||
+ "(SELECT child_comm_id FROM community2community) "
|
String query = "SELECT c.* FROM community c "
|
||||||
+ "ORDER BY name");
|
+ "LEFT JOIN metadatavalue m on (m.resource_id = c.community_id and m.resource_type_id = ? and m.metadata_field_id = ?) "
|
||||||
|
+ "WHERE NOT c.community_id IN (SELECT child_comm_id FROM community2community) ";
|
||||||
|
if(DatabaseManager.isOracle()){
|
||||||
|
query += " ORDER BY cast(m.text_value as varchar2(128))";
|
||||||
|
}else{
|
||||||
|
query += " ORDER BY m.text_value";
|
||||||
|
}
|
||||||
|
tri = DatabaseManager.query(context,
|
||||||
|
query,
|
||||||
|
Constants.COMMUNITY,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID()
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Find all Top Communities - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
List<Community> topCommunities = new ArrayList<Community>();
|
List<Community> topCommunities = new ArrayList<Community>();
|
||||||
|
|
||||||
@@ -393,10 +413,12 @@ public class Community extends DSpaceObject
|
|||||||
* @exception IllegalArgumentException
|
* @exception IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getMetadata(String field)
|
public String getMetadata(String field)
|
||||||
{
|
{
|
||||||
String metadata = communityRow.getStringColumn(field);
|
String[] MDValue = getMDValueByLegacyField(field);
|
||||||
return (metadata == null) ? "" : metadata;
|
String value = getMetadataFirstValue(MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||||
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,8 +433,8 @@ public class Community extends DSpaceObject
|
|||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
* @exception MissingResourceException
|
* @exception MissingResourceException
|
||||||
*/
|
*/
|
||||||
public void setMetadata(String field, String value)throws MissingResourceException
|
@Deprecated
|
||||||
{
|
public void setMetadata(String field, String value) throws MissingResourceException {
|
||||||
if ((field.trim()).equals("name")
|
if ((field.trim()).equals("name")
|
||||||
&& (value == null || value.trim().equals("")))
|
&& (value == null || value.trim().equals("")))
|
||||||
{
|
{
|
||||||
@@ -426,6 +448,8 @@ public class Community extends DSpaceObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] MDValue = getMDValueByLegacyField(field);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set metadata field to null if null
|
* Set metadata field to null if null
|
||||||
* and trim strings to eliminate excess
|
* and trim strings to eliminate excess
|
||||||
@@ -433,20 +457,21 @@ public class Community extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
if(value == null)
|
if(value == null)
|
||||||
{
|
{
|
||||||
communityRow.setColumnNull(field);
|
clearMetadata(MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||||
|
modifiedMetadata = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
communityRow.setColumn(field, value.trim());
|
setMetadataSingleValue(MDValue[0], MDValue[1], MDValue[2], null, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails(field);
|
addDetails(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return getMetadata("name");
|
String value = getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||||
|
return value == null ? "" : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -536,10 +561,7 @@ public class Community extends DSpaceObject
|
|||||||
}
|
}
|
||||||
if (modifiedMetadata)
|
if (modifiedMetadata)
|
||||||
{
|
{
|
||||||
ourContext.addEvent(new Event(Event.MODIFY_METADATA,
|
updateMetadata();
|
||||||
Constants.COMMUNITY, getID(), getDetails(),
|
|
||||||
getIdentifiers(ourContext)));
|
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -629,12 +651,27 @@ public class Community extends DSpaceObject
|
|||||||
List<Collection> collections = new ArrayList<Collection>();
|
List<Collection> collections = new ArrayList<Collection>();
|
||||||
|
|
||||||
// Get the table rows
|
// Get the table rows
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(
|
TableRowIterator tri = null;
|
||||||
ourContext,"collection",
|
try {
|
||||||
"SELECT collection.* FROM collection, community2collection WHERE " +
|
String query = "SELECT c.* FROM community2collection c2c, collection c "
|
||||||
"community2collection.collection_id=collection.collection_id " +
|
+ "LEFT JOIN metadatavalue m on (m.resource_id = c.collection_id and m.resource_type_id = ? and m.metadata_field_id = ?) "
|
||||||
"AND community2collection.community_id= ? ORDER BY collection.name",
|
+ "WHERE c2c.collection_id=c.collection_id AND c2c.community_id=? ";
|
||||||
getID());
|
if(DatabaseManager.isOracle()){
|
||||||
|
query += " ORDER BY cast(m.text_value as varchar2(128))";
|
||||||
|
}else{
|
||||||
|
query += " ORDER BY m.text_value";
|
||||||
|
}
|
||||||
|
tri = DatabaseManager.query(
|
||||||
|
ourContext,
|
||||||
|
query,
|
||||||
|
Constants.COLLECTION,
|
||||||
|
MetadataField.findByElement(ourContext, MetadataSchema.find(ourContext, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID(),
|
||||||
|
getID()
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Find all Collections for this community - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// Make Collection objects
|
// Make Collection objects
|
||||||
try
|
try
|
||||||
@@ -685,12 +722,29 @@ public class Community extends DSpaceObject
|
|||||||
List<Community> subcommunities = new ArrayList<Community>();
|
List<Community> subcommunities = new ArrayList<Community>();
|
||||||
|
|
||||||
// Get the table rows
|
// Get the table rows
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(
|
TableRowIterator tri = null;
|
||||||
ourContext,"community",
|
try {
|
||||||
"SELECT community.* FROM community, community2community WHERE " +
|
String query = "SELECT c.* FROM community2community c2c, community c " +
|
||||||
"community2community.child_comm_id=community.community_id " +
|
"LEFT JOIN metadatavalue m on (m.resource_id = c.community_id and m.resource_type_id = ? and m.metadata_field_id = ?) " +
|
||||||
"AND community2community.parent_comm_id= ? ORDER BY community.name",
|
"WHERE c2c.child_comm_id=c.community_id " +
|
||||||
getID());
|
"AND c2c.parent_comm_id= ? ";
|
||||||
|
if(DatabaseManager.isOracle()){
|
||||||
|
query += " ORDER BY cast(m.text_value as varchar2(128))";
|
||||||
|
}else{
|
||||||
|
query += " ORDER BY m.text_value";
|
||||||
|
}
|
||||||
|
|
||||||
|
tri = DatabaseManager.query(
|
||||||
|
ourContext,
|
||||||
|
query,
|
||||||
|
Constants.COMMUNITY,
|
||||||
|
MetadataField.findByElement(ourContext, MetadataSchema.find(ourContext, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID(),
|
||||||
|
getID()
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Find all Sub Communities - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make Community objects
|
// Make Community objects
|
||||||
@@ -1205,6 +1259,9 @@ public class Community extends DSpaceObject
|
|||||||
// Remove all associated authorization policies
|
// Remove all associated authorization policies
|
||||||
AuthorizeManager.removeAllPolicies(ourContext, this);
|
AuthorizeManager.removeAllPolicies(ourContext, this);
|
||||||
|
|
||||||
|
// Delete the Dublin Core
|
||||||
|
removeMetadataFromDatabase();
|
||||||
|
|
||||||
// get rid of the content count cache if it exists
|
// get rid of the content count cache if it exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -53,6 +53,9 @@ public class MetadataField
|
|||||||
// cache of field by ID (Integer)
|
// cache of field by ID (Integer)
|
||||||
private static Map<Integer, MetadataField> id2field = null;
|
private static Map<Integer, MetadataField> id2field = null;
|
||||||
|
|
||||||
|
/** metadatafield cache */
|
||||||
|
private static Map<String, MetadataField> metadatafieldcache = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
@@ -270,51 +273,20 @@ public class MetadataField
|
|||||||
* @throws AuthorizeException
|
* @throws AuthorizeException
|
||||||
*/
|
*/
|
||||||
public static MetadataField findByElement(Context context, int schemaID,
|
public static MetadataField findByElement(Context context, int schemaID,
|
||||||
String element, String qualifier) throws SQLException,
|
String element, String qualifier) throws SQLException
|
||||||
AuthorizeException
|
|
||||||
{
|
{
|
||||||
// Grab rows from DB
|
|
||||||
TableRowIterator tri;
|
if (!isCacheInitialized()){
|
||||||
if (qualifier == null)
|
initCache(context);
|
||||||
{
|
|
||||||
tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
|
|
||||||
"SELECT * FROM MetadataFieldRegistry WHERE metadata_schema_id= ? " +
|
|
||||||
"AND element= ? AND qualifier is NULL ",
|
|
||||||
schemaID, element);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
|
|
||||||
"SELECT * FROM MetadataFieldRegistry WHERE metadata_schema_id= ? " +
|
|
||||||
"AND element= ? AND qualifier= ? ",
|
|
||||||
schemaID, element, qualifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TableRow row = null;
|
// 'sanity check' first.
|
||||||
try
|
String metadataFieldKey = schemaID+"."+element+"."+qualifier;
|
||||||
{
|
if(!metadatafieldcache.containsKey(metadataFieldKey)) {
|
||||||
if (tri.hasNext())
|
|
||||||
{
|
|
||||||
row = tri.next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// close the TableRowIterator to free up resources
|
|
||||||
if (tri != null)
|
|
||||||
{
|
|
||||||
tri.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row == null)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return metadatafieldcache.get(metadataFieldKey);
|
||||||
return new MetadataField(row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -629,6 +601,7 @@ public class MetadataField
|
|||||||
if (!isCacheInitialized())
|
if (!isCacheInitialized())
|
||||||
{
|
{
|
||||||
Map<Integer, MetadataField> new_id2field = new HashMap<Integer, MetadataField>();
|
Map<Integer, MetadataField> new_id2field = new HashMap<Integer, MetadataField>();
|
||||||
|
Map<String, MetadataField> new_metadatafieldcache = new HashMap<String, MetadataField>();
|
||||||
log.info("Loading MetadataField elements into cache.");
|
log.info("Loading MetadataField elements into cache.");
|
||||||
|
|
||||||
// Grab rows from DB
|
// Grab rows from DB
|
||||||
@@ -641,7 +614,9 @@ public class MetadataField
|
|||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
int fieldID = row.getIntColumn("metadata_field_id");
|
int fieldID = row.getIntColumn("metadata_field_id");
|
||||||
new_id2field.put(Integer.valueOf(fieldID), new MetadataField(row));
|
MetadataField metadataField = new MetadataField(row);
|
||||||
|
new_id2field.put(Integer.valueOf(fieldID), metadataField);
|
||||||
|
new_metadatafieldcache.put(metadataField.getSchemaID()+"."+metadataField.getElement()+"."+metadataField.getQualifier(), metadataField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -654,6 +629,7 @@ public class MetadataField
|
|||||||
}
|
}
|
||||||
|
|
||||||
id2field = new_id2field;
|
id2field = new_id2field;
|
||||||
|
metadatafieldcache = new_metadatafieldcache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,8 +38,11 @@ public class MetadataValue
|
|||||||
/** The primary key for the metadata value */
|
/** The primary key for the metadata value */
|
||||||
private int valueId = 0;
|
private int valueId = 0;
|
||||||
|
|
||||||
/** The reference to the DSpace item */
|
/** The reference to the DSpace resource */
|
||||||
private int itemId;
|
private int resourceId;
|
||||||
|
|
||||||
|
/** The reference to the DSpace resource type*/
|
||||||
|
private int resourceTypeId;
|
||||||
|
|
||||||
/** The value of the field */
|
/** The value of the field */
|
||||||
public String value;
|
public String value;
|
||||||
@@ -73,7 +76,8 @@ public class MetadataValue
|
|||||||
{
|
{
|
||||||
fieldId = row.getIntColumn("metadata_field_id");
|
fieldId = row.getIntColumn("metadata_field_id");
|
||||||
valueId = row.getIntColumn("metadata_value_id");
|
valueId = row.getIntColumn("metadata_value_id");
|
||||||
itemId = row.getIntColumn("item_id");
|
resourceId = row.getIntColumn("resource_id");
|
||||||
|
resourceTypeId = row.getIntColumn("resource_type_id");
|
||||||
value = row.getStringColumn("text_value");
|
value = row.getStringColumn("text_value");
|
||||||
language = row.getStringColumn("text_lang");
|
language = row.getStringColumn("text_lang");
|
||||||
place = row.getIntColumn("place");
|
place = row.getIntColumn("place");
|
||||||
@@ -121,23 +125,39 @@ public class MetadataValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the item ID.
|
* Get the resource type ID.
|
||||||
*
|
*
|
||||||
* @return item ID
|
* @return resource type ID
|
||||||
*/
|
*/
|
||||||
public int getItemId()
|
public int getResourceTypeId() {
|
||||||
{
|
return resourceTypeId;
|
||||||
return itemId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the item ID.
|
* Set the resource type ID.
|
||||||
*
|
*
|
||||||
* @param itemId new item ID
|
* @param resourceTypeId new resource type ID
|
||||||
*/
|
*/
|
||||||
public void setItemId(int itemId)
|
public void setResourceTypeId(int resourceTypeId) {
|
||||||
{
|
this.resourceTypeId = resourceTypeId;
|
||||||
this.itemId = itemId;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the resource id
|
||||||
|
*
|
||||||
|
* @return resource ID
|
||||||
|
*/
|
||||||
|
public int getResourceId() {
|
||||||
|
return resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the resource type ID.
|
||||||
|
*
|
||||||
|
* @param resourceId new resource ID
|
||||||
|
*/
|
||||||
|
public void setResourceId(int resourceId) {
|
||||||
|
this.resourceId = resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,7 +282,8 @@ public class MetadataValue
|
|||||||
{
|
{
|
||||||
// Create a table row and update it with the values
|
// Create a table row and update it with the values
|
||||||
row = DatabaseManager.row("MetadataValue");
|
row = DatabaseManager.row("MetadataValue");
|
||||||
row.setColumn("item_id", itemId);
|
row.setColumn("resource_id", resourceId);
|
||||||
|
row.setColumn("resource_type_id", resourceTypeId);
|
||||||
row.setColumn("metadata_field_id", fieldId);
|
row.setColumn("metadata_field_id", fieldId);
|
||||||
row.setColumn("text_value", value);
|
row.setColumn("text_value", value);
|
||||||
row.setColumn("text_lang", language);
|
row.setColumn("text_lang", language);
|
||||||
@@ -372,7 +393,8 @@ public class MetadataValue
|
|||||||
*/
|
*/
|
||||||
public void update(Context context) throws SQLException, AuthorizeException
|
public void update(Context context) throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
row.setColumn("item_id", itemId);
|
row.setColumn("resource_id", resourceId);
|
||||||
|
row.setColumn("resource_type_id", resourceTypeId);
|
||||||
row.setColumn("metadata_field_id", fieldId);
|
row.setColumn("metadata_field_id", fieldId);
|
||||||
row.setColumn("text_value", value);
|
row.setColumn("text_value", value);
|
||||||
row.setColumn("text_lang", language);
|
row.setColumn("text_lang", language);
|
||||||
@@ -429,7 +451,11 @@ public class MetadataValue
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.itemId != other.itemId)
|
if (this.resourceId != other.resourceId)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.resourceTypeId != other.resourceTypeId)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -442,7 +468,8 @@ public class MetadataValue
|
|||||||
int hash = 7;
|
int hash = 7;
|
||||||
hash = 47 * hash + this.fieldId;
|
hash = 47 * hash + this.fieldId;
|
||||||
hash = 47 * hash + this.valueId;
|
hash = 47 * hash + this.valueId;
|
||||||
hash = 47 * hash + this.itemId;
|
hash = 47 * hash + this.resourceId;
|
||||||
|
hash = 47 * hash + this.resourceTypeId;
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -105,8 +105,7 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
"WHERE epersongroup2workspaceitem.workspace_item_id" +
|
"WHERE epersongroup2workspaceitem.workspace_item_id" +
|
||||||
" = ? " +
|
" = ? " +
|
||||||
" AND epersongroup2workspaceitem.eperson_group_id =" +
|
" AND epersongroup2workspaceitem.eperson_group_id =" +
|
||||||
" epersongroup.eperson_group_id " +
|
" epersongroup.eperson_group_id ";
|
||||||
"ORDER BY epersongroup.name";
|
|
||||||
|
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(c,"epersongroup",query, wi);
|
TableRowIterator tri = DatabaseManager.queryTable(c,"epersongroup",query, wi);
|
||||||
|
|
||||||
@@ -151,8 +150,7 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
"WHERE epersongroup2workspaceitem.workspace_item_id" +
|
"WHERE epersongroup2workspaceitem.workspace_item_id" +
|
||||||
" = ? " +
|
" = ? " +
|
||||||
" AND epersongroup2workspaceitem.eperson_group_id =" +
|
" AND epersongroup2workspaceitem.eperson_group_id =" +
|
||||||
" epersongroup.eperson_group_id " +
|
" epersongroup.eperson_group_id ";
|
||||||
"ORDER BY epersongroup.name";
|
|
||||||
|
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(ourContext,
|
TableRowIterator tri = DatabaseManager.queryTable(ourContext,
|
||||||
"epersongroup",
|
"epersongroup",
|
||||||
|
@@ -53,7 +53,7 @@ public class ItemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getFirstMetadataValue(Item item, String metadataKey) {
|
public static String getFirstMetadataValue(Item item, String metadataKey) {
|
||||||
DCValue[] dcValue = item.getMetadata(metadataKey);
|
DCValue[] dcValue = item.getMetadataByMetadataString(metadataKey);
|
||||||
if(dcValue.length > 0) {
|
if(dcValue.length > 0) {
|
||||||
return dcValue[0].value;
|
return dcValue[0].value;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -89,7 +89,7 @@ public abstract class AbstractTranslator extends AbstractCurationTask
|
|||||||
String handle = item.getHandle();
|
String handle = item.getHandle();
|
||||||
log.debug("Translating metadata for " + handle);
|
log.debug("Translating metadata for " + handle);
|
||||||
|
|
||||||
DCValue[] authLangs = item.getMetadata(authLangField);
|
DCValue[] authLangs = item.getMetadataByMetadataString(authLangField);
|
||||||
if(authLangs.length > 0)
|
if(authLangs.length > 0)
|
||||||
{
|
{
|
||||||
/* Assume the first... multiple
|
/* Assume the first... multiple
|
||||||
|
@@ -236,7 +236,7 @@ public class MetadataWebService extends AbstractCurationTask implements Namespac
|
|||||||
}
|
}
|
||||||
resultSb.append(itemId);
|
resultSb.append(itemId);
|
||||||
// Only proceed if item has a value for service template parameter
|
// Only proceed if item has a value for service template parameter
|
||||||
DCValue[] dcVals = item.getMetadata(lookupField);
|
DCValue[] dcVals = item.getMetadataByMetadataString(lookupField);
|
||||||
if (dcVals.length > 0 && dcVals[0].value.length() > 0) {
|
if (dcVals.length > 0 && dcVals[0].value.length() > 0) {
|
||||||
String value = transform(dcVals[0].value, lookupTransform);
|
String value = transform(dcVals[0].value, lookupTransform);
|
||||||
status = callService(value, item, resultSb);
|
status = callService(value, item, resultSb);
|
||||||
|
@@ -81,7 +81,7 @@ public class RequiredMetadata extends AbstractCurationTask
|
|||||||
sb.append("Item: ").append(handle);
|
sb.append("Item: ").append(handle);
|
||||||
for (String req : getReqList(item.getOwningCollection().getHandle()))
|
for (String req : getReqList(item.getOwningCollection().getHandle()))
|
||||||
{
|
{
|
||||||
DCValue[] vals = item.getMetadata(req);
|
DCValue[] vals = item.getMetadataByMetadataString(req);
|
||||||
if (vals.length == 0)
|
if (vals.length == 0)
|
||||||
{
|
{
|
||||||
sb.append(" missing required field: ").append(req);
|
sb.append(" missing required field: ").append(req);
|
||||||
|
@@ -1320,7 +1320,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
DCValue[] values = item.getMetadata("dc.relation.ispartof");
|
DCValue[] values = item.getMetadataByMetadataString("dc.relation.ispartof");
|
||||||
|
|
||||||
if(values != null && values.length > 0 && values[0] != null && values[0].value != null)
|
if(values != null && values.length > 0 && values[0] != null && values[0].value != null)
|
||||||
{
|
{
|
||||||
|
@@ -24,7 +24,7 @@ import org.apache.commons.codec.DecoderException;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.AuthorizeManager;
|
import org.dspace.authorize.AuthorizeManager;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.*;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -61,18 +61,12 @@ public class EPerson extends DSpaceObject
|
|||||||
/** log4j logger */
|
/** log4j logger */
|
||||||
private static final Logger log = Logger.getLogger(EPerson.class);
|
private static final Logger log = Logger.getLogger(EPerson.class);
|
||||||
|
|
||||||
/** Our context */
|
|
||||||
private final Context myContext;
|
|
||||||
|
|
||||||
/** The row in the table representing this eperson */
|
/** The row in the table representing this eperson */
|
||||||
private final TableRow myRow;
|
private final TableRow myRow;
|
||||||
|
|
||||||
/** Flag set when data is modified, for events */
|
/** Flag set when data is modified, for events */
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
/** Flag set when metadata is modified, for events */
|
|
||||||
private boolean modifiedMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an EPerson
|
* Construct an EPerson
|
||||||
*
|
*
|
||||||
@@ -81,15 +75,13 @@ public class EPerson extends DSpaceObject
|
|||||||
* @param row
|
* @param row
|
||||||
* the corresponding row in the table
|
* the corresponding row in the table
|
||||||
*/
|
*/
|
||||||
EPerson(Context context, TableRow row)
|
EPerson(Context context, TableRow row) throws SQLException {
|
||||||
{
|
super(context);
|
||||||
myContext = context;
|
|
||||||
myRow = row;
|
myRow = row;
|
||||||
|
|
||||||
// Cache ourselves
|
// Cache ourselves
|
||||||
context.cache(this, row.getIntColumn("eperson_id"));
|
context.cache(this, row.getIntColumn("eperson_id"));
|
||||||
modified = false;
|
modified = false;
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,8 +282,17 @@ public class EPerson extends DSpaceObject
|
|||||||
{
|
{
|
||||||
String params = "%"+query.toLowerCase()+"%";
|
String params = "%"+query.toLowerCase()+"%";
|
||||||
StringBuffer queryBuf = new StringBuffer();
|
StringBuffer queryBuf = new StringBuffer();
|
||||||
queryBuf.append("SELECT * FROM eperson WHERE eperson_id = ? OR ");
|
queryBuf.append("select e.* from eperson e " +
|
||||||
queryBuf.append("LOWER(firstname) LIKE LOWER(?) OR LOWER(lastname) LIKE LOWER(?) OR LOWER(email) LIKE LOWER(?) ORDER BY lastname, firstname ASC ");
|
" LEFT JOIN metadatavalue fn on (resource_id=e.eperson_id AND fn.resource_type_id=? and fn.metadata_field_id=?) " +
|
||||||
|
" LEFT JOIN metadatavalue ln on (ln.resource_id=e.eperson_id AND ln.resource_type_id=? and ln.metadata_field_id=?) " +
|
||||||
|
" WHERE e.eperson_id = ? OR " +
|
||||||
|
"LOWER(fn.text_value) LIKE LOWER(?) OR LOWER(ln.text_value) LIKE LOWER(?) OR LOWER(email) LIKE LOWER(?) ORDER BY ");
|
||||||
|
|
||||||
|
if(DatabaseManager.isOracle()) {
|
||||||
|
queryBuf.append(" dbms_lob.substr(ln.text_value), dbms_lob.substr(fn.text_value) ASC");
|
||||||
|
}else{
|
||||||
|
queryBuf.append(" ln.text_value, fn.text_value ASC");
|
||||||
|
}
|
||||||
|
|
||||||
// Add offset and limit restrictions - Oracle requires special code
|
// Add offset and limit restrictions - Oracle requires special code
|
||||||
if (DatabaseManager.isOracle())
|
if (DatabaseManager.isOracle())
|
||||||
@@ -341,23 +342,28 @@ public class EPerson extends DSpaceObject
|
|||||||
try {
|
try {
|
||||||
int_param = Integer.valueOf(query);
|
int_param = Integer.valueOf(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
int_param = Integer.valueOf(-1);
|
int_param = Integer.valueOf(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Integer f = MetadataField.findByElement(context, MetadataSchema.find(context, "eperson").getSchemaID(), "firstname", null).getFieldID();
|
||||||
|
Integer l = MetadataField.findByElement(context, MetadataSchema.find(context, "eperson").getSchemaID(), "lastname", null).getFieldID();
|
||||||
|
|
||||||
// Create the parameter array, including limit and offset if part of the query
|
// Create the parameter array, including limit and offset if part of the query
|
||||||
Object[] paramArr = new Object[] {int_param,params,params,params};
|
Object[] paramArr = new Object[] {Constants.EPERSON,f, Constants.EPERSON,l, int_param,params,params,params};
|
||||||
if (limit > 0 && offset > 0)
|
if (limit > 0 && offset > 0)
|
||||||
{
|
{
|
||||||
paramArr = new Object[]{int_param, params, params, params, limit, offset};
|
paramArr = new Object[]{Constants.EPERSON,f, Constants.EPERSON,l, int_param,params,params,params, limit, offset};
|
||||||
}
|
}
|
||||||
else if (limit > 0)
|
else if (limit > 0)
|
||||||
{
|
{
|
||||||
paramArr = new Object[]{int_param, params, params, params, limit};
|
paramArr = new Object[]{Constants.EPERSON,f, Constants.EPERSON,l, int_param,params,params,params, limit};
|
||||||
}
|
}
|
||||||
else if (offset > 0)
|
else if (offset > 0)
|
||||||
{
|
{
|
||||||
paramArr = new Object[]{int_param, params, params, params, offset};
|
paramArr = new Object[]{Constants.EPERSON,f, Constants.EPERSON,l, int_param,params,params,params, offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all the epeople that match the query
|
// Get all the epeople that match the query
|
||||||
@@ -425,9 +431,26 @@ public class EPerson extends DSpaceObject
|
|||||||
|
|
||||||
// Get all the epeople that match the query
|
// Get all the epeople that match the query
|
||||||
TableRow row = DatabaseManager.querySingle(context,
|
TableRow row = DatabaseManager.querySingle(context,
|
||||||
"SELECT count(*) as epcount FROM eperson WHERE eperson_id = ? OR " +
|
"SELECT count(*) as epcount FROM eperson " +
|
||||||
"LOWER(firstname) LIKE LOWER(?) OR LOWER(lastname) LIKE LOWER(?) OR LOWER(email) LIKE LOWER(?)",
|
"WHERE eperson_id = ? OR " +
|
||||||
new Object[] {int_param,dbquery,dbquery,dbquery});
|
"LOWER((select text_value from metadatavalue where resource_id=? and resource_type_id=? and metadata_field_id=?)) LIKE LOWER(?) " +
|
||||||
|
"OR LOWER((select text_value from metadatavalue where resource_id=? and resource_type_id=? and metadata_field_id=?)) LIKE LOWER(?) " +
|
||||||
|
"OR LOWER(eperson.email) LIKE LOWER(?)",
|
||||||
|
new Object[] {
|
||||||
|
int_param,
|
||||||
|
|
||||||
|
int_param,
|
||||||
|
Constants.EPERSON,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, "eperson").getSchemaID(), "firstname", null).getFieldID(),
|
||||||
|
dbquery,
|
||||||
|
|
||||||
|
int_param,
|
||||||
|
Constants.EPERSON,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, "eperson").getSchemaID(), "lastname", null).getFieldID(),
|
||||||
|
dbquery,
|
||||||
|
|
||||||
|
dbquery
|
||||||
|
});
|
||||||
|
|
||||||
// use getIntColumn for Oracle count data
|
// use getIntColumn for Oracle count data
|
||||||
if (DatabaseManager.isOracle())
|
if (DatabaseManager.isOracle())
|
||||||
@@ -458,33 +481,47 @@ public class EPerson extends DSpaceObject
|
|||||||
public static EPerson[] findAll(Context context, int sortField)
|
public static EPerson[] findAll(Context context, int sortField)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
String s;
|
String s, t = "", theQuery = "";
|
||||||
|
|
||||||
switch (sortField)
|
switch (sortField)
|
||||||
{
|
{
|
||||||
case ID:
|
case ID:
|
||||||
s = "eperson_id";
|
s = "e.eperson_id";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMAIL:
|
case EMAIL:
|
||||||
s = "email";
|
s = "e.email";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LANGUAGE:
|
case LANGUAGE:
|
||||||
s = "language";
|
s = "m_text_value";
|
||||||
|
t = "language";
|
||||||
break;
|
break;
|
||||||
case NETID:
|
case NETID:
|
||||||
s = "netid";
|
s = "m_text_value";
|
||||||
|
t = "netid";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
s = "lastname";
|
s = "m_text_value";
|
||||||
|
t = "lastname";
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The use of 's' in the order by clause can not cause an SQL
|
// NOTE: The use of 's' in the order by clause can not cause an SQL
|
||||||
// injection because the string is derived from constant values above.
|
// injection because the string is derived from constant values above.
|
||||||
TableRowIterator rows = DatabaseManager.query(context,
|
TableRowIterator rows = DatabaseManager.query(context, "SELECT * FROM eperson e ORDER BY ?",s);
|
||||||
"SELECT * FROM eperson ORDER BY "+s);
|
if(t!="") {
|
||||||
|
rows = DatabaseManager.query(context,
|
||||||
|
"SELECT * FROM eperson e " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = e.eperson_id and m.resource_type_id = ? and m.metadata_field_id = ?) " +
|
||||||
|
"ORDER BY ?",
|
||||||
|
Constants.EPERSON,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, "eperson").getSchemaID(), t, null).getFieldID(),
|
||||||
|
s
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -559,7 +596,7 @@ public class EPerson extends DSpaceObject
|
|||||||
EPersonDeletionException
|
EPersonDeletionException
|
||||||
{
|
{
|
||||||
// authorized?
|
// authorized?
|
||||||
if (!AuthorizeManager.isAdmin(myContext))
|
if (!AuthorizeManager.isAdmin(ourContext))
|
||||||
{
|
{
|
||||||
throw new AuthorizeException(
|
throw new AuthorizeException(
|
||||||
"You must be an admin to delete an EPerson");
|
"You must be an admin to delete an EPerson");
|
||||||
@@ -576,29 +613,31 @@ public class EPerson extends DSpaceObject
|
|||||||
throw new EPersonDeletionException(constraintList);
|
throw new EPersonDeletionException(constraintList);
|
||||||
}
|
}
|
||||||
|
|
||||||
myContext.addEvent(new Event(Event.DELETE, Constants.EPERSON, getID(),
|
// Delete the Dublin Core
|
||||||
getEmail(), getIdentifiers(myContext)));
|
removeMetadataFromDatabase();
|
||||||
|
|
||||||
|
ourContext.addEvent(new Event(Event.DELETE, Constants.EPERSON, getID(), getEmail(), getIdentifiers(ourContext)));
|
||||||
|
|
||||||
// Remove from cache
|
// Remove from cache
|
||||||
myContext.removeCached(this, getID());
|
ourContext.removeCached(this, getID());
|
||||||
|
|
||||||
// XXX FIXME: This sidesteps the object model code so it won't
|
// XXX FIXME: This sidesteps the object model code so it won't
|
||||||
// generate REMOVE events on the affected Groups.
|
// generate REMOVE events on the affected Groups.
|
||||||
|
|
||||||
// Remove any group memberships first
|
// Remove any group memberships first
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM EPersonGroup2EPerson WHERE eperson_id= ? ",
|
"DELETE FROM EPersonGroup2EPerson WHERE eperson_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
// Remove any subscriptions
|
// Remove any subscriptions
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM subscription WHERE eperson_id= ? ",
|
"DELETE FROM subscription WHERE eperson_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
// Remove ourself
|
// Remove ourself
|
||||||
DatabaseManager.delete(myContext, myRow);
|
DatabaseManager.delete(ourContext, myRow);
|
||||||
|
|
||||||
log.info(LogManager.getHeader(myContext, "delete_eperson",
|
log.info(LogManager.getHeader(ourContext, "delete_eperson",
|
||||||
"eperson_id=" + getID()));
|
"eperson_id=" + getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,7 +658,7 @@ public class EPerson extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getLanguage()
|
public String getLanguage()
|
||||||
{
|
{
|
||||||
return myRow.getStringColumn("language");
|
return getMetadataFirstValue("eperson", "language", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -630,9 +669,8 @@ public class EPerson extends DSpaceObject
|
|||||||
* @param language
|
* @param language
|
||||||
* language code
|
* language code
|
||||||
*/
|
*/
|
||||||
public void setLanguage(String language)
|
public void setLanguage(String language) {
|
||||||
{
|
setMetadataSingleValue("eperson", "language", null, null, language);
|
||||||
myRow.setColumn("language", language);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -681,7 +719,7 @@ public class EPerson extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getNetid()
|
public String getNetid()
|
||||||
{
|
{
|
||||||
return myRow.getStringColumn("netid");
|
return getMetadataFirstValue("eperson", "netid", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -690,9 +728,8 @@ public class EPerson extends DSpaceObject
|
|||||||
* @param s
|
* @param s
|
||||||
* the new netid
|
* the new netid
|
||||||
*/
|
*/
|
||||||
public void setNetid(String s)
|
public void setNetid(String s) {
|
||||||
{
|
setMetadataSingleValue("eperson", "netid", null, null, s);
|
||||||
myRow.setColumn("netid", s);
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,8 +741,8 @@ public class EPerson extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getFullName()
|
public String getFullName()
|
||||||
{
|
{
|
||||||
String f = myRow.getStringColumn("firstname");
|
String f = getFirstName();
|
||||||
String l = myRow.getStringColumn("lastname");
|
String l= getLastName();
|
||||||
|
|
||||||
if ((l == null) && (f == null))
|
if ((l == null) && (f == null))
|
||||||
{
|
{
|
||||||
@@ -728,7 +765,7 @@ public class EPerson extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getFirstName()
|
public String getFirstName()
|
||||||
{
|
{
|
||||||
return myRow.getStringColumn("firstname");
|
return getMetadataFirstValue("eperson", "firstname", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -737,9 +774,8 @@ public class EPerson extends DSpaceObject
|
|||||||
* @param firstname
|
* @param firstname
|
||||||
* the person's first name
|
* the person's first name
|
||||||
*/
|
*/
|
||||||
public void setFirstName(String firstname)
|
public void setFirstName(String firstname) {
|
||||||
{
|
setMetadataSingleValue("eperson", "firstname", null, null, firstname);
|
||||||
myRow.setColumn("firstname", firstname);
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,7 +786,7 @@ public class EPerson extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getLastName()
|
public String getLastName()
|
||||||
{
|
{
|
||||||
return myRow.getStringColumn("lastname");
|
return getMetadataFirstValue("eperson", "lastname", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -759,9 +795,8 @@ public class EPerson extends DSpaceObject
|
|||||||
* @param lastname
|
* @param lastname
|
||||||
* the person's last name
|
* the person's last name
|
||||||
*/
|
*/
|
||||||
public void setLastName(String lastname)
|
public void setLastName(String lastname) {
|
||||||
{
|
setMetadataSingleValue("eperson", "lastname", null, null, lastname);
|
||||||
myRow.setColumn("lastname", lastname);
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -842,9 +877,11 @@ public class EPerson extends DSpaceObject
|
|||||||
* @exception IllegalArgumentException
|
* @exception IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getMetadata(String field)
|
public String getMetadata(String field)
|
||||||
{
|
{
|
||||||
return myRow.getStringColumn(field);
|
String[] MDValue = getMDValueByLegacyField(field);
|
||||||
|
return getMetadataFirstValue(MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -858,11 +895,11 @@ public class EPerson extends DSpaceObject
|
|||||||
* @exception IllegalArgumentException
|
* @exception IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setMetadata(String field, String value)
|
public void setMetadata(String field, String value)
|
||||||
{
|
{
|
||||||
myRow.setColumn(field, value);
|
String[] MDValue = getMDValueByLegacyField(field);
|
||||||
modifiedMetadata = true;
|
setMetadataSingleValue(MDValue[0], MDValue[1], MDValue[2], null, value);
|
||||||
addDetails(field);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -951,14 +988,14 @@ public class EPerson extends DSpaceObject
|
|||||||
log.info("Upgrading password hash for EPerson " + getID());
|
log.info("Upgrading password hash for EPerson " + getID());
|
||||||
setPassword(attempt);
|
setPassword(attempt);
|
||||||
try {
|
try {
|
||||||
myContext.turnOffAuthorisationSystem();
|
ourContext.turnOffAuthorisationSystem();
|
||||||
update();
|
update();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
log.error("Could not update password hash", ex);
|
log.error("Could not update password hash", ex);
|
||||||
} catch (AuthorizeException ex) {
|
} catch (AuthorizeException ex) {
|
||||||
log.error("Could not update password hash", ex);
|
log.error("Could not update password hash", ex);
|
||||||
} finally {
|
} finally {
|
||||||
myContext.restoreAuthSystemState();
|
ourContext.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,29 +1029,27 @@ public class EPerson extends DSpaceObject
|
|||||||
{
|
{
|
||||||
// Check authorisation - if you're not the eperson
|
// Check authorisation - if you're not the eperson
|
||||||
// see if the authorization system says you can
|
// see if the authorization system says you can
|
||||||
if (!myContext.ignoreAuthorization()
|
if (!ourContext.ignoreAuthorization()
|
||||||
&& ((myContext.getCurrentUser() == null) || (getID() != myContext
|
&& ((ourContext.getCurrentUser() == null) || (getID() != ourContext
|
||||||
.getCurrentUser().getID())))
|
.getCurrentUser().getID())))
|
||||||
{
|
{
|
||||||
AuthorizeManager.authorizeAction(myContext, this, Constants.WRITE);
|
AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseManager.update(myContext, myRow);
|
DatabaseManager.update(ourContext, myRow);
|
||||||
|
|
||||||
log.info(LogManager.getHeader(myContext, "update_eperson",
|
log.info(LogManager.getHeader(ourContext, "update_eperson",
|
||||||
"eperson_id=" + getID()));
|
"eperson_id=" + getID()));
|
||||||
|
|
||||||
if (modified)
|
if (modified)
|
||||||
{
|
{
|
||||||
myContext.addEvent(new Event(Event.MODIFY, Constants.EPERSON,
|
ourContext.addEvent(new Event(Event.MODIFY, Constants.EPERSON,
|
||||||
getID(), null, getIdentifiers(myContext)));
|
getID(), null, getIdentifiers(ourContext)));
|
||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
if (modifiedMetadata)
|
if (modifiedMetadata)
|
||||||
{
|
{
|
||||||
myContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.EPERSON,
|
updateMetadata();
|
||||||
getID(), getDetails(), getIdentifiers(myContext)));
|
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1077,7 @@ public class EPerson extends DSpaceObject
|
|||||||
List<String> tableList = new ArrayList<String>();
|
List<String> tableList = new ArrayList<String>();
|
||||||
|
|
||||||
// check for eperson in item table
|
// check for eperson in item table
|
||||||
TableRowIterator tri = DatabaseManager.query(myContext,
|
TableRowIterator tri = DatabaseManager.query(ourContext,
|
||||||
"SELECT * from item where submitter_id= ? ",
|
"SELECT * from item where submitter_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1076,7 +1111,7 @@ public class EPerson extends DSpaceObject
|
|||||||
private void getXMLWorkflowConstraints(List<String> tableList) throws SQLException {
|
private void getXMLWorkflowConstraints(List<String> tableList) throws SQLException {
|
||||||
TableRowIterator tri;
|
TableRowIterator tri;
|
||||||
// check for eperson in claimtask table
|
// check for eperson in claimtask table
|
||||||
tri = DatabaseManager.queryTable(myContext, "cwf_claimtask",
|
tri = DatabaseManager.queryTable(ourContext, "cwf_claimtask",
|
||||||
"SELECT * from cwf_claimtask where owner_id= ? ",
|
"SELECT * from cwf_claimtask where owner_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1097,7 +1132,7 @@ public class EPerson extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for eperson in pooltask table
|
// check for eperson in pooltask table
|
||||||
tri = DatabaseManager.queryTable(myContext, "cwf_pooltask",
|
tri = DatabaseManager.queryTable(ourContext, "cwf_pooltask",
|
||||||
"SELECT * from cwf_pooltask where eperson_id= ? ",
|
"SELECT * from cwf_pooltask where eperson_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1118,7 +1153,7 @@ public class EPerson extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for eperson in workflowitemrole table
|
// check for eperson in workflowitemrole table
|
||||||
tri = DatabaseManager.queryTable(myContext, "cwf_workflowitemrole",
|
tri = DatabaseManager.queryTable(ourContext, "cwf_workflowitemrole",
|
||||||
"SELECT * from cwf_workflowitemrole where eperson_id= ? ",
|
"SELECT * from cwf_workflowitemrole where eperson_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1143,7 +1178,7 @@ public class EPerson extends DSpaceObject
|
|||||||
private void getOriginalWorkflowConstraints(List<String> tableList) throws SQLException {
|
private void getOriginalWorkflowConstraints(List<String> tableList) throws SQLException {
|
||||||
TableRowIterator tri;
|
TableRowIterator tri;
|
||||||
// check for eperson in workflowitem table
|
// check for eperson in workflowitem table
|
||||||
tri = DatabaseManager.query(myContext,
|
tri = DatabaseManager.query(ourContext,
|
||||||
"SELECT * from workflowitem where owner= ? ",
|
"SELECT * from workflowitem where owner= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1164,7 +1199,7 @@ public class EPerson extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for eperson in tasklistitem table
|
// check for eperson in tasklistitem table
|
||||||
tri = DatabaseManager.query(myContext,
|
tri = DatabaseManager.query(ourContext,
|
||||||
"SELECT * from tasklistitem where eperson_id= ? ",
|
"SELECT * from tasklistitem where eperson_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1223,8 +1258,7 @@ public class EPerson extends DSpaceObject
|
|||||||
* Tool for manipulating user accounts.
|
* Tool for manipulating user accounts.
|
||||||
*/
|
*/
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
throws ParseException, SQLException
|
throws ParseException, SQLException, AuthorizeException {
|
||||||
{
|
|
||||||
final OptionGroup VERBS = new OptionGroup();
|
final OptionGroup VERBS = new OptionGroup();
|
||||||
VERBS.addOption(VERB_ADD);
|
VERBS.addOption(VERB_ADD);
|
||||||
VERBS.addOption(VERB_DELETE);
|
VERBS.addOption(VERB_DELETE);
|
||||||
@@ -1284,8 +1318,7 @@ public class EPerson extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Command to create an EPerson. */
|
/** Command to create an EPerson. */
|
||||||
private static int cmdAdd(Context context, String[] argv)
|
private static int cmdAdd(Context context, String[] argv) throws AuthorizeException {
|
||||||
{
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption(VERB_ADD);
|
options.addOption(VERB_ADD);
|
||||||
@@ -1455,8 +1488,7 @@ public class EPerson extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Command to modify an EPerson. */
|
/** Command to modify an EPerson. */
|
||||||
private static int cmdModify(Context context, String[] argv)
|
private static int cmdModify(Context context, String[] argv) throws AuthorizeException {
|
||||||
{
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption(VERB_MODIFY);
|
options.addOption(VERB_MODIFY);
|
||||||
|
@@ -20,9 +20,7 @@ import org.apache.log4j.Logger;
|
|||||||
import org.dspace.authorize.AuthorizeConfiguration;
|
import org.dspace.authorize.AuthorizeConfiguration;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.AuthorizeManager;
|
import org.dspace.authorize.AuthorizeManager;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.*;
|
||||||
import org.dspace.content.Community;
|
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -54,9 +52,6 @@ public class Group extends DSpaceObject
|
|||||||
/** ID of Administrator Group */
|
/** ID of Administrator Group */
|
||||||
public static final int ADMIN_ID = 1;
|
public static final int ADMIN_ID = 1;
|
||||||
|
|
||||||
/** Our context */
|
|
||||||
private final Context myContext;
|
|
||||||
|
|
||||||
/** The row in the table representing this object */
|
/** The row in the table representing this object */
|
||||||
private final TableRow myRow;
|
private final TableRow myRow;
|
||||||
|
|
||||||
@@ -73,8 +68,6 @@ public class Group extends DSpaceObject
|
|||||||
/** is this just a stub, or is all data loaded? */
|
/** is this just a stub, or is all data loaded? */
|
||||||
private boolean isDataLoaded = false;
|
private boolean isDataLoaded = false;
|
||||||
|
|
||||||
/** Flag set when metadata is modified, for events */
|
|
||||||
private boolean modifiedMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a Group from a given context and tablerow
|
* Construct a Group from a given context and tablerow
|
||||||
@@ -84,13 +77,12 @@ public class Group extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
Group(Context context, TableRow row) throws SQLException
|
Group(Context context, TableRow row) throws SQLException
|
||||||
{
|
{
|
||||||
myContext = context;
|
super(context);
|
||||||
myRow = row;
|
myRow = row;
|
||||||
|
|
||||||
// Cache ourselves
|
// Cache ourselves
|
||||||
context.cache(this, row.getIntColumn("eperson_group_id"));
|
context.cache(this, row.getIntColumn("eperson_group_id"));
|
||||||
|
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +102,7 @@ public class Group extends DSpaceObject
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// get epeople objects
|
// get epeople objects
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(myContext,"eperson",
|
TableRowIterator tri = DatabaseManager.queryTable(ourContext,"eperson",
|
||||||
"SELECT eperson.* FROM eperson, epersongroup2eperson WHERE " +
|
"SELECT eperson.* FROM eperson, epersongroup2eperson WHERE " +
|
||||||
"epersongroup2eperson.eperson_id=eperson.eperson_id AND " +
|
"epersongroup2eperson.eperson_id=eperson.eperson_id AND " +
|
||||||
"epersongroup2eperson.eperson_group_id= ?",
|
"epersongroup2eperson.eperson_group_id= ?",
|
||||||
@@ -123,7 +115,7 @@ public class Group extends DSpaceObject
|
|||||||
TableRow r = (TableRow) tri.next();
|
TableRow r = (TableRow) tri.next();
|
||||||
|
|
||||||
// First check the cache
|
// First check the cache
|
||||||
EPerson fromCache = (EPerson) myContext.fromCache(
|
EPerson fromCache = (EPerson) ourContext.fromCache(
|
||||||
EPerson.class, r.getIntColumn("eperson_id"));
|
EPerson.class, r.getIntColumn("eperson_id"));
|
||||||
|
|
||||||
if (fromCache != null)
|
if (fromCache != null)
|
||||||
@@ -132,7 +124,7 @@ public class Group extends DSpaceObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
epeople.add(new EPerson(myContext, r));
|
epeople.add(new EPerson(ourContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +138,7 @@ public class Group extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now get Group objects
|
// now get Group objects
|
||||||
tri = DatabaseManager.queryTable(myContext,"epersongroup",
|
tri = DatabaseManager.queryTable(ourContext,"epersongroup",
|
||||||
"SELECT epersongroup.* FROM epersongroup, group2group WHERE " +
|
"SELECT epersongroup.* FROM epersongroup, group2group WHERE " +
|
||||||
"group2group.child_id=epersongroup.eperson_group_id AND "+
|
"group2group.child_id=epersongroup.eperson_group_id AND "+
|
||||||
"group2group.parent_id= ? ",
|
"group2group.parent_id= ? ",
|
||||||
@@ -159,7 +151,7 @@ public class Group extends DSpaceObject
|
|||||||
TableRow r = (TableRow) tri.next();
|
TableRow r = (TableRow) tri.next();
|
||||||
|
|
||||||
// First check the cache
|
// First check the cache
|
||||||
Group fromCache = (Group) myContext.fromCache(Group.class,
|
Group fromCache = (Group) ourContext.fromCache(Group.class,
|
||||||
r.getIntColumn("eperson_group_id"));
|
r.getIntColumn("eperson_group_id"));
|
||||||
|
|
||||||
if (fromCache != null)
|
if (fromCache != null)
|
||||||
@@ -168,7 +160,7 @@ public class Group extends DSpaceObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
groups.add(new Group(myContext, r));
|
groups.add(new Group(ourContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +229,7 @@ public class Group extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return myRow.getStringColumn("name");
|
return getMetadataFirstValue(MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -246,11 +238,8 @@ public class Group extends DSpaceObject
|
|||||||
* @param name
|
* @param name
|
||||||
* new group name
|
* new group name
|
||||||
*/
|
*/
|
||||||
public void setName(String name)
|
public void setName(String name) {
|
||||||
{
|
setMetadataSingleValue(MetadataSchema.DC_SCHEMA, "title", null, null, name);
|
||||||
myRow.setColumn("name", name);
|
|
||||||
modifiedMetadata = true;
|
|
||||||
addDetails("name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -271,9 +260,7 @@ public class Group extends DSpaceObject
|
|||||||
epeople.add(e);
|
epeople.add(e);
|
||||||
epeopleChanged = true;
|
epeopleChanged = true;
|
||||||
|
|
||||||
myContext.addEvent(new Event(Event.ADD, Constants.GROUP, getID(),
|
ourContext.addEvent(new Event(Event.ADD, Constants.GROUP, getID(), Constants.EPERSON, e.getID(), e.getEmail(), getIdentifiers(ourContext)));
|
||||||
Constants.EPERSON, e.getID(), e.getEmail(),
|
|
||||||
getIdentifiers(myContext)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,9 +282,7 @@ public class Group extends DSpaceObject
|
|||||||
groups.add(g);
|
groups.add(g);
|
||||||
groupsChanged = true;
|
groupsChanged = true;
|
||||||
|
|
||||||
myContext.addEvent(new Event(Event.ADD, Constants.GROUP, getID(),
|
ourContext.addEvent(new Event(Event.ADD, Constants.GROUP, getID(), Constants.GROUP, g.getID(), g.getName(), getIdentifiers(ourContext)));
|
||||||
Constants.GROUP, g.getID(), g.getName(),
|
|
||||||
getIdentifiers(myContext)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,9 +298,7 @@ public class Group extends DSpaceObject
|
|||||||
if (epeople.remove(e))
|
if (epeople.remove(e))
|
||||||
{
|
{
|
||||||
epeopleChanged = true;
|
epeopleChanged = true;
|
||||||
myContext.addEvent(new Event(Event.REMOVE, Constants.GROUP, getID(),
|
ourContext.addEvent(new Event(Event.REMOVE, Constants.GROUP, getID(), Constants.EPERSON, e.getID(), e.getEmail(), getIdentifiers(ourContext)));
|
||||||
Constants.EPERSON, e.getID(), e.getEmail(),
|
|
||||||
getIdentifiers(myContext)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,9 +314,7 @@ public class Group extends DSpaceObject
|
|||||||
if (groups.remove(g))
|
if (groups.remove(g))
|
||||||
{
|
{
|
||||||
groupsChanged = true;
|
groupsChanged = true;
|
||||||
myContext.addEvent(new Event(Event.REMOVE, Constants.GROUP, getID(),
|
ourContext.addEvent(new Event(Event.REMOVE, Constants.GROUP, getID(), Constants.GROUP, g.getID(), g.getName(), getIdentifiers(ourContext)));
|
||||||
Constants.GROUP, g.getID(), g.getName(),
|
|
||||||
getIdentifiers(myContext)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,8 +698,20 @@ public class Group extends DSpaceObject
|
|||||||
public static Group findByName(Context context, String name)
|
public static Group findByName(Context context, String name)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
TableRow row = DatabaseManager.findByUnique(context, "epersongroup",
|
String query = "select * from epersongroup e " +
|
||||||
"name", name);
|
"LEFT JOIN metadatavalue m on (m.resource_id = e.eperson_group_id and m.resource_type_id = ? and m.metadata_field_id = ?) " +
|
||||||
|
"where ";
|
||||||
|
if(DatabaseManager.isOracle()) {
|
||||||
|
query += " dbms_lob.substr(m.text_value) = ?";
|
||||||
|
}else{
|
||||||
|
query += " m.text_value = ?";
|
||||||
|
|
||||||
|
}
|
||||||
|
TableRow row = DatabaseManager.querySingle(context, query,
|
||||||
|
Constants.GROUP,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID(),
|
||||||
|
name
|
||||||
|
);
|
||||||
|
|
||||||
if (row == null)
|
if (row == null)
|
||||||
{
|
{
|
||||||
@@ -759,24 +752,31 @@ public class Group extends DSpaceObject
|
|||||||
switch (sortField)
|
switch (sortField)
|
||||||
{
|
{
|
||||||
case ID:
|
case ID:
|
||||||
s = "eperson_group_id";
|
s = "e.eperson_group_id";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME:
|
case NAME:
|
||||||
s = "name";
|
s = "m_text_value";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
s = "name";
|
s = "m_text_value";
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The use of 's' in the order by clause can not cause an SQL
|
// NOTE: The use of 's' in the order by clause can not cause an SQL
|
||||||
// injection because the string is derived from constant values above.
|
// injection because the string is derived from constant values above.
|
||||||
TableRowIterator rows = DatabaseManager.queryTable(
|
TableRowIterator rows = DatabaseManager.query(
|
||||||
context, "epersongroup",
|
context,
|
||||||
"SELECT * FROM epersongroup ORDER BY "+s);
|
"select e.* from epersongroup e " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = e.eperson_group_id and m.resource_type_id = ? and m.metadata_field_id = ?) " +
|
||||||
|
"order by ?",
|
||||||
|
Constants.GROUP,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID(),
|
||||||
|
s
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -849,7 +849,16 @@ public class Group extends DSpaceObject
|
|||||||
{
|
{
|
||||||
String params = "%"+query.toLowerCase()+"%";
|
String params = "%"+query.toLowerCase()+"%";
|
||||||
StringBuffer queryBuf = new StringBuffer();
|
StringBuffer queryBuf = new StringBuffer();
|
||||||
queryBuf.append("SELECT * FROM epersongroup WHERE LOWER(name) LIKE LOWER(?) OR eperson_group_id = ? ORDER BY name ASC ");
|
queryBuf.append("SELECT * FROM epersongroup " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = epersongroup.eperson_group_id and m.resource_type_id = ? and m.metadata_field_id = ?) " +
|
||||||
|
"WHERE LOWER(m.text_value) LIKE LOWER(?) OR eperson_group_id = ? ");
|
||||||
|
|
||||||
|
if(DatabaseManager.isOracle()){
|
||||||
|
queryBuf.append(" ORDER BY cast(m.text_value as varchar2(128))");
|
||||||
|
}else{
|
||||||
|
queryBuf.append(" ORDER BY m.text_value");
|
||||||
|
}
|
||||||
|
queryBuf.append(" ASC");
|
||||||
|
|
||||||
// Add offset and limit restrictions - Oracle requires special code
|
// Add offset and limit restrictions - Oracle requires special code
|
||||||
if (DatabaseManager.isOracle())
|
if (DatabaseManager.isOracle())
|
||||||
@@ -904,18 +913,21 @@ public class Group extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the parameter array, including limit and offset if part of the query
|
// Create the parameter array, including limit and offset if part of the query
|
||||||
Object[] paramArr = new Object[]{params, int_param};
|
|
||||||
|
int metadataFieldId = MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID();
|
||||||
|
|
||||||
|
Object[] paramArr = new Object[]{Constants.GROUP, metadataFieldId, params, int_param};
|
||||||
if (limit > 0 && offset > 0)
|
if (limit > 0 && offset > 0)
|
||||||
{
|
{
|
||||||
paramArr = new Object[]{params, int_param, limit, offset};
|
paramArr = new Object[]{Constants.GROUP, metadataFieldId,params, int_param, limit, offset};
|
||||||
}
|
}
|
||||||
else if (limit > 0)
|
else if (limit > 0)
|
||||||
{
|
{
|
||||||
paramArr = new Object[]{params, int_param, limit};
|
paramArr = new Object[]{Constants.GROUP, metadataFieldId,params, int_param, limit};
|
||||||
}
|
}
|
||||||
else if (offset > 0)
|
else if (offset > 0)
|
||||||
{
|
{
|
||||||
paramArr = new Object[]{params, int_param, offset};
|
paramArr = new Object[]{Constants.GROUP, metadataFieldId,params, int_param, offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
TableRowIterator rows =
|
TableRowIterator rows =
|
||||||
@@ -969,7 +981,9 @@ public class Group extends DSpaceObject
|
|||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
String params = "%"+query.toLowerCase()+"%";
|
String params = "%"+query.toLowerCase()+"%";
|
||||||
String dbquery = "SELECT count(*) as gcount FROM epersongroup WHERE LOWER(name) LIKE LOWER(?) OR eperson_group_id = ? ";
|
String dbquery = "SELECT count(*) as gcount FROM epersongroup " +
|
||||||
|
"LEFT JOIN metadatavalue m on (m.resource_id = epersongroup.eperson_group_id and m.resource_type_id = ? and m.metadata_field_id = ?) " +
|
||||||
|
"WHERE LOWER(m.text_value) LIKE LOWER(?) OR eperson_group_id = ? ";
|
||||||
|
|
||||||
// When checking against the eperson-id, make sure the query can be made into a number
|
// When checking against the eperson-id, make sure the query can be made into a number
|
||||||
Integer int_param;
|
Integer int_param;
|
||||||
@@ -981,7 +995,16 @@ public class Group extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get all the epeople that match the query
|
// Get all the epeople that match the query
|
||||||
TableRow row = DatabaseManager.querySingle(context, dbquery, new Object[] {params, int_param});
|
TableRow row = DatabaseManager.querySingle(
|
||||||
|
context,
|
||||||
|
dbquery,
|
||||||
|
new Object[] {
|
||||||
|
Constants.GROUP,
|
||||||
|
MetadataField.findByElement(context, MetadataSchema.find(context, MetadataSchema.DC_SCHEMA).getSchemaID(), "title", null).getFieldID(),
|
||||||
|
params,
|
||||||
|
int_param
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// use getIntColumn for Oracle count data
|
// use getIntColumn for Oracle count data
|
||||||
Long count;
|
Long count;
|
||||||
@@ -1006,40 +1029,43 @@ public class Group extends DSpaceObject
|
|||||||
{
|
{
|
||||||
// FIXME: authorizations
|
// FIXME: authorizations
|
||||||
|
|
||||||
myContext.addEvent(new Event(Event.DELETE, Constants.GROUP, getID(),
|
ourContext.addEvent(new Event(Event.DELETE, Constants.GROUP, getID(), getName(), getIdentifiers(ourContext)));
|
||||||
getName(), getIdentifiers(myContext)));
|
|
||||||
|
|
||||||
// Remove from cache
|
// Remove from cache
|
||||||
myContext.removeCached(this, getID());
|
ourContext.removeCached(this, getID());
|
||||||
|
|
||||||
// Remove any ResourcePolicies that reference this group
|
// Remove any ResourcePolicies that reference this group
|
||||||
AuthorizeManager.removeGroupPolicies(myContext, getID());
|
AuthorizeManager.removeGroupPolicies(ourContext, getID());
|
||||||
|
|
||||||
// Remove any group memberships first
|
// Remove any group memberships first
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM EPersonGroup2EPerson WHERE eperson_group_id= ? ",
|
"DELETE FROM EPersonGroup2EPerson WHERE eperson_group_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
// remove any group2groupcache entries
|
// remove any group2groupcache entries
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM group2groupcache WHERE parent_id= ? OR child_id= ? ",
|
"DELETE FROM group2groupcache WHERE parent_id= ? OR child_id= ? ",
|
||||||
getID(),getID());
|
getID(),getID());
|
||||||
|
|
||||||
// Now remove any group2group assignments
|
// Now remove any group2group assignments
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM group2group WHERE parent_id= ? OR child_id= ? ",
|
"DELETE FROM group2group WHERE parent_id= ? OR child_id= ? ",
|
||||||
getID(),getID());
|
getID(),getID());
|
||||||
|
|
||||||
|
// Delete the Dublin Core
|
||||||
|
removeMetadataFromDatabase();
|
||||||
|
|
||||||
// don't forget the new table
|
// don't forget the new table
|
||||||
deleteEpersonGroup2WorkspaceItem();
|
deleteEpersonGroup2WorkspaceItem();
|
||||||
|
|
||||||
// Remove ourself
|
// Remove ourself
|
||||||
DatabaseManager.delete(myContext, myRow);
|
DatabaseManager.delete(ourContext, myRow);
|
||||||
|
|
||||||
epeople.clear();
|
epeople.clear();
|
||||||
|
|
||||||
log.info(LogManager.getHeader(myContext, "delete_group", "group_id="
|
log.info(LogManager.getHeader(ourContext, "delete_group", "group_id="
|
||||||
+ getID()));
|
+ getID()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1047,7 +1073,7 @@ public class Group extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
private void deleteEpersonGroup2WorkspaceItem() throws SQLException
|
private void deleteEpersonGroup2WorkspaceItem() throws SQLException
|
||||||
{
|
{
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM EPersonGroup2WorkspaceItem WHERE eperson_group_id= ? ",
|
"DELETE FROM EPersonGroup2WorkspaceItem WHERE eperson_group_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
}
|
}
|
||||||
@@ -1111,13 +1137,11 @@ public class Group extends DSpaceObject
|
|||||||
public void update() throws SQLException, AuthorizeException
|
public void update() throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
// FIXME: Check authorisation
|
// FIXME: Check authorisation
|
||||||
DatabaseManager.update(myContext, myRow);
|
DatabaseManager.update(ourContext, myRow);
|
||||||
|
|
||||||
if (modifiedMetadata)
|
if (modifiedMetadata)
|
||||||
{
|
{
|
||||||
myContext.addEvent(new Event(Event.MODIFY_METADATA, Constants.GROUP,
|
updateMetadata();
|
||||||
getID(), getDetails(), getIdentifiers(myContext)));
|
|
||||||
modifiedMetadata = false;
|
|
||||||
clearDetails();
|
clearDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1125,7 +1149,7 @@ public class Group extends DSpaceObject
|
|||||||
if (epeopleChanged)
|
if (epeopleChanged)
|
||||||
{
|
{
|
||||||
// Remove any existing mappings
|
// Remove any existing mappings
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"delete from epersongroup2eperson where eperson_group_id= ? ",
|
"delete from epersongroup2eperson where eperson_group_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1139,7 +1163,7 @@ public class Group extends DSpaceObject
|
|||||||
TableRow mappingRow = DatabaseManager.row("epersongroup2eperson");
|
TableRow mappingRow = DatabaseManager.row("epersongroup2eperson");
|
||||||
mappingRow.setColumn("eperson_id", e.getID());
|
mappingRow.setColumn("eperson_id", e.getID());
|
||||||
mappingRow.setColumn("eperson_group_id", getID());
|
mappingRow.setColumn("eperson_group_id", getID());
|
||||||
DatabaseManager.insert(myContext, mappingRow);
|
DatabaseManager.insert(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
epeopleChanged = false;
|
epeopleChanged = false;
|
||||||
@@ -1149,7 +1173,7 @@ public class Group extends DSpaceObject
|
|||||||
if (groupsChanged)
|
if (groupsChanged)
|
||||||
{
|
{
|
||||||
// Remove any existing mappings
|
// Remove any existing mappings
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"delete from group2group where parent_id= ? ",
|
"delete from group2group where parent_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
@@ -1163,7 +1187,7 @@ public class Group extends DSpaceObject
|
|||||||
TableRow mappingRow = DatabaseManager.row("group2group");
|
TableRow mappingRow = DatabaseManager.row("group2group");
|
||||||
mappingRow.setColumn("parent_id", getID());
|
mappingRow.setColumn("parent_id", getID());
|
||||||
mappingRow.setColumn("child_id", g.getID());
|
mappingRow.setColumn("child_id", g.getID());
|
||||||
DatabaseManager.insert(myContext, mappingRow);
|
DatabaseManager.insert(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// groups changed, now change group cache
|
// groups changed, now change group cache
|
||||||
@@ -1172,7 +1196,7 @@ public class Group extends DSpaceObject
|
|||||||
groupsChanged = false;
|
groupsChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(LogManager.getHeader(myContext, "update_group", "group_id="
|
log.info(LogManager.getHeader(ourContext, "update_group", "group_id="
|
||||||
+ getID()));
|
+ getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1233,7 +1257,7 @@ public class Group extends DSpaceObject
|
|||||||
private void rethinkGroupCache() throws SQLException
|
private void rethinkGroupCache() throws SQLException
|
||||||
{
|
{
|
||||||
// read in the group2group table
|
// read in the group2group table
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(myContext, "group2group",
|
TableRowIterator tri = DatabaseManager.queryTable(ourContext, "group2group",
|
||||||
"SELECT * FROM group2group");
|
"SELECT * FROM group2group");
|
||||||
|
|
||||||
Map<Integer,Set<Integer>> parents = new HashMap<Integer,Set<Integer>>();
|
Map<Integer,Set<Integer>> parents = new HashMap<Integer,Set<Integer>>();
|
||||||
@@ -1286,7 +1310,7 @@ public class Group extends DSpaceObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// empty out group2groupcache table
|
// empty out group2groupcache table
|
||||||
DatabaseManager.updateQuery(myContext,
|
DatabaseManager.updateQuery(ourContext,
|
||||||
"DELETE FROM group2groupcache WHERE id >= 0");
|
"DELETE FROM group2groupcache WHERE id >= 0");
|
||||||
|
|
||||||
// write out new one
|
// write out new one
|
||||||
@@ -1301,7 +1325,7 @@ public class Group extends DSpaceObject
|
|||||||
row.setColumn("parent_id", parentID);
|
row.setColumn("parent_id", parentID);
|
||||||
row.setColumn("child_id", child);
|
row.setColumn("child_id", child);
|
||||||
|
|
||||||
DatabaseManager.insert(myContext, row);
|
DatabaseManager.insert(ourContext, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1365,7 +1389,7 @@ public class Group extends DSpaceObject
|
|||||||
// is this a collection related group?
|
// is this a collection related group?
|
||||||
TableRow qResult = DatabaseManager
|
TableRow qResult = DatabaseManager
|
||||||
.querySingle(
|
.querySingle(
|
||||||
myContext,
|
ourContext,
|
||||||
"SELECT collection_id, workflow_step_1, workflow_step_2, " +
|
"SELECT collection_id, workflow_step_1, workflow_step_2, " +
|
||||||
" workflow_step_3, submitter, admin FROM collection "
|
" workflow_step_3, submitter, admin FROM collection "
|
||||||
+ " WHERE workflow_step_1 = ? OR "
|
+ " WHERE workflow_step_1 = ? OR "
|
||||||
@@ -1375,7 +1399,7 @@ public class Group extends DSpaceObject
|
|||||||
getID(), getID(), getID(), getID(), getID());
|
getID(), getID(), getID(), getID(), getID());
|
||||||
if (qResult != null)
|
if (qResult != null)
|
||||||
{
|
{
|
||||||
Collection collection = Collection.find(myContext, qResult
|
Collection collection = Collection.find(ourContext, qResult
|
||||||
.getIntColumn("collection_id"));
|
.getIntColumn("collection_id"));
|
||||||
|
|
||||||
if ((qResult.getIntColumn("workflow_step_1") == getID() ||
|
if ((qResult.getIntColumn("workflow_step_1") == getID() ||
|
||||||
@@ -1418,13 +1442,13 @@ public class Group extends DSpaceObject
|
|||||||
// to manage it?
|
// to manage it?
|
||||||
else if (AuthorizeConfiguration.canCommunityAdminManageAdminGroup())
|
else if (AuthorizeConfiguration.canCommunityAdminManageAdminGroup())
|
||||||
{
|
{
|
||||||
qResult = DatabaseManager.querySingle(myContext,
|
qResult = DatabaseManager.querySingle(ourContext,
|
||||||
"SELECT community_id FROM community "
|
"SELECT community_id FROM community "
|
||||||
+ "WHERE admin = ?", getID());
|
+ "WHERE admin = ?", getID());
|
||||||
|
|
||||||
if (qResult != null)
|
if (qResult != null)
|
||||||
{
|
{
|
||||||
Community community = Community.find(myContext, qResult
|
Community community = Community.find(ourContext, qResult
|
||||||
.getIntColumn("community_id"));
|
.getIntColumn("community_id"));
|
||||||
return community;
|
return community;
|
||||||
}
|
}
|
||||||
@@ -1438,4 +1462,37 @@ public class Group extends DSpaceObject
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main script used to set the group names for anonymous group & admin group, only to be called once on DSpace fresh_install
|
||||||
|
* @param args not used
|
||||||
|
* @throws SQLException database exception
|
||||||
|
* @throws AuthorizeException should not occur since we disable authentication for this method.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) throws SQLException, AuthorizeException {
|
||||||
|
Context context = new Context();
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
initDefaultGroupNames(context);
|
||||||
|
|
||||||
|
//Clear the events to avoid the consumers which aren't needed at this time
|
||||||
|
context.getEvents().clear();
|
||||||
|
context.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the group names for anymous & administrator
|
||||||
|
* @param context the dspace context
|
||||||
|
* @throws SQLException database exception
|
||||||
|
* @throws AuthorizeException
|
||||||
|
*/
|
||||||
|
public static void initDefaultGroupNames(Context context) throws SQLException, AuthorizeException {
|
||||||
|
Group anonymousGroup = Group.find(context, 0);
|
||||||
|
anonymousGroup.setName("Anonymous");
|
||||||
|
anonymousGroup.update();
|
||||||
|
|
||||||
|
Group adminGroup = Group.find(context, 1);
|
||||||
|
adminGroup.setName("Administrator");
|
||||||
|
adminGroup.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -629,7 +629,7 @@ public class EZIDIdentifierProvider
|
|||||||
|
|
||||||
for (Entry<String, String> datum : crosswalk.entrySet())
|
for (Entry<String, String> datum : crosswalk.entrySet())
|
||||||
{
|
{
|
||||||
DCValue[] values = item.getMetadata(datum.getValue());
|
DCValue[] values = item.getMetadataByMetadataString(datum.getValue());
|
||||||
if (null != values)
|
if (null != values)
|
||||||
{
|
{
|
||||||
for (DCValue value : values)
|
for (DCValue value : values)
|
||||||
|
@@ -114,16 +114,17 @@ public class DatabaseManager
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void setConstraintDeferred(Context context,
|
public static void setConstraintDeferred(Context context,
|
||||||
String constraintName) throws SQLException
|
String constraintName) throws SQLException {
|
||||||
{
|
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
statement = context.getDBConnection().createStatement();
|
statement = context.getDBConnection().createStatement();
|
||||||
statement.execute("SET CONSTRAINTS " + constraintName + " DEFERRED");
|
statement.execute("SET CONSTRAINTS " + constraintName + " DEFERRED");
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
finally
|
log.error("SQL setConstraintDeferred Error - ", e);
|
||||||
|
throw e;
|
||||||
|
} finally
|
||||||
{
|
{
|
||||||
if (statement != null)
|
if (statement != null)
|
||||||
{
|
{
|
||||||
@@ -133,6 +134,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL setConstraintDeferred close Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,16 +151,17 @@ public class DatabaseManager
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void setConstraintImmediate(Context context,
|
public static void setConstraintImmediate(Context context,
|
||||||
String constraintName) throws SQLException
|
String constraintName) throws SQLException {
|
||||||
{
|
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
statement = context.getDBConnection().createStatement();
|
statement = context.getDBConnection().createStatement();
|
||||||
statement.execute("SET CONSTRAINTS " + constraintName + " IMMEDIATE");
|
statement.execute("SET CONSTRAINTS " + constraintName + " IMMEDIATE");
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
finally
|
log.error("SQL setConstraintImmediate Error - ", e);
|
||||||
|
throw e;
|
||||||
|
} finally
|
||||||
{
|
{
|
||||||
if (statement != null)
|
if (statement != null)
|
||||||
{
|
{
|
||||||
@@ -167,6 +171,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL setConstraintImmediate Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,8 +197,7 @@ public class DatabaseManager
|
|||||||
* @exception SQLException
|
* @exception SQLException
|
||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static TableRowIterator queryTable(Context context, String table, String query, Object... parameters ) throws SQLException
|
public static TableRowIterator queryTable(Context context, String table, String query, Object... parameters ) throws SQLException {
|
||||||
{
|
|
||||||
if (log.isDebugEnabled())
|
if (log.isDebugEnabled())
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder("Running query \"").append(query).append("\" with parameters: ");
|
StringBuilder sb = new StringBuilder("Running query \"").append(query).append("\" with parameters: ");
|
||||||
@@ -207,9 +212,11 @@ public class DatabaseManager
|
|||||||
log.debug(sb.toString());
|
log.debug(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement statement = context.getDBConnection().prepareStatement(query);
|
PreparedStatement statement = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
statement = context.getDBConnection().prepareStatement(query);
|
||||||
|
|
||||||
loadParameters(statement, parameters);
|
loadParameters(statement, parameters);
|
||||||
|
|
||||||
TableRowIterator retTRI = new TableRowIterator(statement.executeQuery(), canonicalize(table));
|
TableRowIterator retTRI = new TableRowIterator(statement.executeQuery(), canonicalize(table));
|
||||||
@@ -227,9 +234,11 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException s)
|
catch (SQLException s)
|
||||||
{
|
{
|
||||||
|
log.error("SQL QueryTable close Error - ",s);
|
||||||
|
throw s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.error("SQL QueryTable Error - ",sqle);
|
||||||
throw sqle;
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,9 +295,11 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException s)
|
catch (SQLException s)
|
||||||
{
|
{
|
||||||
|
log.error("SQL query exec close Error - ",s);
|
||||||
|
throw s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.error("SQL query exec Error - ",sqle);
|
||||||
throw sqle;
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,16 +322,17 @@ public class DatabaseManager
|
|||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static TableRow querySingle(Context context, String query,
|
public static TableRow querySingle(Context context, String query,
|
||||||
Object... parameters) throws SQLException
|
Object... parameters) throws SQLException {
|
||||||
{
|
|
||||||
TableRow retRow = null;
|
TableRow retRow = null;
|
||||||
TableRowIterator iterator = null;
|
TableRowIterator iterator = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
iterator = query(context, query, parameters);
|
iterator = query(context, query, parameters);
|
||||||
retRow = (!iterator.hasNext()) ? null : iterator.next();
|
retRow = (!iterator.hasNext()) ? null : iterator.next();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
finally
|
log.error("SQL query single Error - ", e);
|
||||||
|
throw e;
|
||||||
|
} finally
|
||||||
{
|
{
|
||||||
if (iterator != null)
|
if (iterator != null)
|
||||||
{
|
{
|
||||||
@@ -350,16 +362,23 @@ public class DatabaseManager
|
|||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static TableRow querySingleTable(Context context, String table,
|
public static TableRow querySingleTable(Context context, String table,
|
||||||
String query, Object... parameters) throws SQLException
|
String query, Object... parameters) throws SQLException {
|
||||||
{
|
|
||||||
TableRow retRow = null;
|
TableRow retRow = null;
|
||||||
TableRowIterator iterator = queryTable(context, canonicalize(table), query, parameters);
|
TableRowIterator iterator = null;
|
||||||
|
try {
|
||||||
|
iterator = queryTable(context, canonicalize(table), query, parameters);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL query singleTable Error - ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
retRow = (!iterator.hasNext()) ? null : iterator.next();
|
retRow = (!iterator.hasNext()) ? null : iterator.next();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
finally
|
log.error("SQL query singleTable Error - ", e);
|
||||||
|
throw e;
|
||||||
|
} finally
|
||||||
{
|
{
|
||||||
if (iterator != null)
|
if (iterator != null)
|
||||||
{
|
{
|
||||||
@@ -385,8 +404,7 @@ public class DatabaseManager
|
|||||||
* @exception SQLException
|
* @exception SQLException
|
||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static int updateQuery(Context context, String query, Object... parameters) throws SQLException
|
public static int updateQuery(Context context, String query, Object... parameters) throws SQLException {
|
||||||
{
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
if (log.isDebugEnabled())
|
if (log.isDebugEnabled())
|
||||||
@@ -409,8 +427,10 @@ public class DatabaseManager
|
|||||||
loadParameters(statement, parameters);
|
loadParameters(statement, parameters);
|
||||||
|
|
||||||
return statement.executeUpdate();
|
return statement.executeUpdate();
|
||||||
}
|
} catch (SQLException e) {
|
||||||
finally
|
log.error("SQL query updateQuery Error - ", e);
|
||||||
|
throw e;
|
||||||
|
} finally
|
||||||
{
|
{
|
||||||
if (statement != null)
|
if (statement != null)
|
||||||
{
|
{
|
||||||
@@ -420,6 +440,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL updateQuery Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -434,13 +456,17 @@ public class DatabaseManager
|
|||||||
* The RDBMS table in which to create the new row
|
* The RDBMS table in which to create the new row
|
||||||
* @return The newly created row
|
* @return The newly created row
|
||||||
*/
|
*/
|
||||||
public static TableRow create(Context context, String table)
|
public static TableRow create(Context context, String table) throws SQLException
|
||||||
throws SQLException
|
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
TableRow row = new TableRow(canonicalize(table), getColumnNames(table));
|
TableRow row = new TableRow(canonicalize(table), getColumnNames(table));
|
||||||
insert(context, row);
|
insert(context, row);
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL create Error - ",e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -458,13 +484,18 @@ public class DatabaseManager
|
|||||||
* @exception SQLException
|
* @exception SQLException
|
||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static TableRow find(Context context, String table, int id)
|
public static TableRow find(Context context, String table, int id) throws SQLException
|
||||||
throws SQLException
|
|
||||||
{
|
{
|
||||||
String ctable = canonicalize(table);
|
String ctable = canonicalize(table);
|
||||||
|
|
||||||
|
try {
|
||||||
return findByUnique(context, ctable, getPrimaryKeyColumn(ctable),
|
return findByUnique(context, ctable, getPrimaryKeyColumn(ctable),
|
||||||
Integer.valueOf(id));
|
Integer.valueOf(id));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL find Error - ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -486,10 +517,10 @@ public class DatabaseManager
|
|||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static TableRow findByUnique(Context context, String table,
|
public static TableRow findByUnique(Context context, String table,
|
||||||
String column, Object value) throws SQLException
|
String column, Object value) throws SQLException {
|
||||||
{
|
|
||||||
String ctable = canonicalize(table);
|
String ctable = canonicalize(table);
|
||||||
|
|
||||||
|
try {
|
||||||
if ( ! DB_SAFE_NAME.matcher(ctable).matches())
|
if ( ! DB_SAFE_NAME.matcher(ctable).matches())
|
||||||
{
|
{
|
||||||
throw new SQLException("Unable to execute select query because table name (" + ctable + ") contains non alphanumeric characters.");
|
throw new SQLException("Unable to execute select query because table name (" + ctable + ") contains non alphanumeric characters.");
|
||||||
@@ -499,9 +530,12 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
throw new SQLException("Unable to execute select query because column name (" + column + ") contains non alphanumeric characters.");
|
throw new SQLException("Unable to execute select query because column name (" + column + ") contains non alphanumeric characters.");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder("select * from ").append(ctable).append(" where ").append(column).append(" = ? ");
|
StringBuilder sql = new StringBuilder("select * from ").append(ctable).append(" where ").append(column).append(" = ? ");
|
||||||
return querySingleTable(context, ctable, sql.toString(), value);
|
return querySingleTable(context, ctable, sql.toString(), value);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL findByUnique Error - ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -518,13 +552,16 @@ public class DatabaseManager
|
|||||||
* @exception SQLException
|
* @exception SQLException
|
||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
public static int delete(Context context, String table, int id)
|
public static int delete(Context context, String table, int id) throws SQLException
|
||||||
throws SQLException
|
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
String ctable = canonicalize(table);
|
String ctable = canonicalize(table);
|
||||||
|
|
||||||
return deleteByValue(context, ctable, getPrimaryKeyColumn(ctable),
|
return deleteByValue(context, ctable, getPrimaryKeyColumn(ctable),
|
||||||
Integer.valueOf(id));
|
Integer.valueOf(id));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL delete Error - ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -546,6 +583,7 @@ public class DatabaseManager
|
|||||||
public static int deleteByValue(Context context, String table,
|
public static int deleteByValue(Context context, String table,
|
||||||
String column, Object value) throws SQLException
|
String column, Object value) throws SQLException
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
String ctable = canonicalize(table);
|
String ctable = canonicalize(table);
|
||||||
|
|
||||||
if ( ! DB_SAFE_NAME.matcher(ctable).matches())
|
if ( ! DB_SAFE_NAME.matcher(ctable).matches())
|
||||||
@@ -560,6 +598,10 @@ public class DatabaseManager
|
|||||||
|
|
||||||
StringBuilder sql = new StringBuilder("delete from ").append(ctable).append(" where ").append(column).append(" = ? ");
|
StringBuilder sql = new StringBuilder("delete from ").append(ctable).append(" where ").append(column).append(" = ? ");
|
||||||
return updateQuery(context, sql.toString(), value);
|
return updateQuery(context, sql.toString(), value);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL deleteByValue Error - ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -572,6 +614,7 @@ public class DatabaseManager
|
|||||||
*/
|
*/
|
||||||
public static Connection getConnection() throws SQLException
|
public static Connection getConnection() throws SQLException
|
||||||
{
|
{
|
||||||
|
try{
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
if (dataSource != null) {
|
if (dataSource != null) {
|
||||||
@@ -581,6 +624,10 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("SQL connection Error - ", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataSource getDataSource()
|
public static DataSource getDataSource()
|
||||||
@@ -591,6 +638,7 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
log.error("SQL getDataSource Error - ",e);
|
||||||
throw new IllegalStateException(e.getMessage(), e);
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,6 +903,7 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
|
log.error("IOE loadSQL Error - ",ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,6 +1316,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL execute Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1297,6 +1348,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL executeUpdate Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1772,6 +1825,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL doInsertPostgresrs close Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1783,6 +1838,8 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
catch (SQLException sqle)
|
catch (SQLException sqle)
|
||||||
{
|
{
|
||||||
|
log.error("SQL doInsertPostgres statement close Error - ",sqle);
|
||||||
|
throw sqle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -171,7 +171,7 @@ public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (item.getMetadata(metadata).length == 0
|
if (item.getMetadataByMetadataString(metadata).length == 0
|
||||||
|| addedMetadata.contains(metadata))
|
|| addedMetadata.contains(metadata))
|
||||||
{
|
{
|
||||||
addedMetadata.add(metadata);
|
addedMetadata.add(metadata);
|
||||||
|
@@ -145,9 +145,9 @@ public class DescribeStep extends AbstractProcessingStep
|
|||||||
|
|
||||||
// Fetch the document type (dc.type)
|
// Fetch the document type (dc.type)
|
||||||
String documentType = "";
|
String documentType = "";
|
||||||
if( (item.getMetadata("dc.type") != null) && (item.getMetadata("dc.type").length >0) )
|
if( (item.getMetadataByMetadataString("dc.type") != null) && (item.getMetadataByMetadataString("dc.type").length >0) )
|
||||||
{
|
{
|
||||||
documentType = item.getMetadata("dc.type")[0].value;
|
documentType = item.getMetadataByMetadataString("dc.type")[0].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1:
|
// Step 1:
|
||||||
|
@@ -36,6 +36,7 @@ import org.dspace.core.I18nUtil;
|
|||||||
import org.dspace.discovery.IndexingService;
|
import org.dspace.discovery.IndexingService;
|
||||||
import org.dspace.discovery.MockIndexEventConsumer;
|
import org.dspace.discovery.MockIndexEventConsumer;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||||
import org.dspace.storage.rdbms.DatabaseManager;
|
import org.dspace.storage.rdbms.DatabaseManager;
|
||||||
@@ -148,6 +149,8 @@ public class AbstractUnitTest
|
|||||||
|
|
||||||
RegistryLoader.loadBitstreamFormats(ctx, base + "bitstream-formats.xml");
|
RegistryLoader.loadBitstreamFormats(ctx, base + "bitstream-formats.xml");
|
||||||
MetadataImporter.loadRegistry(base + "dublin-core-types.xml", true);
|
MetadataImporter.loadRegistry(base + "dublin-core-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "eperson-types.xml", true);
|
||||||
|
MetadataImporter.loadRegistry(base + "bitstream-formats.xml", true);
|
||||||
MetadataImporter.loadRegistry(base + "sword-metadata.xml", true);
|
MetadataImporter.loadRegistry(base + "sword-metadata.xml", true);
|
||||||
ctx.commit();
|
ctx.commit();
|
||||||
|
|
||||||
@@ -173,6 +176,7 @@ public class AbstractUnitTest
|
|||||||
dspace = null;
|
dspace = null;
|
||||||
indexer = null;
|
indexer = null;
|
||||||
}
|
}
|
||||||
|
Group.initDefaultGroupNames(ctx);
|
||||||
ctx.restoreAuthSystemState();
|
ctx.restoreAuthSystemState();
|
||||||
if(ctx.isValid())
|
if(ctx.isValid())
|
||||||
{
|
{
|
||||||
|
@@ -222,9 +222,7 @@ public class CollectionTest extends AbstractDSpaceObjectTest
|
|||||||
assertThat("testGetMetadata 0",c.getMetadata("name"), equalTo(""));
|
assertThat("testGetMetadata 0",c.getMetadata("name"), equalTo(""));
|
||||||
assertThat("testGetMetadata 1",c.getMetadata("short_description"), equalTo(""));
|
assertThat("testGetMetadata 1",c.getMetadata("short_description"), equalTo(""));
|
||||||
assertThat("testGetMetadata 2",c.getMetadata("introductory_text"), equalTo(""));
|
assertThat("testGetMetadata 2",c.getMetadata("introductory_text"), equalTo(""));
|
||||||
assertThat("testGetMetadata 3",c.getMetadata("logo_bitstream_id"), equalTo(""));
|
|
||||||
assertThat("testGetMetadata 4",c.getMetadata("copyright_text"), equalTo(""));
|
assertThat("testGetMetadata 4",c.getMetadata("copyright_text"), equalTo(""));
|
||||||
assertThat("testGetMetadata 5",c.getMetadata("template_item_id"), equalTo(""));
|
|
||||||
assertThat("testGetMetadata 6",c.getMetadata("provenance_description"), equalTo(""));
|
assertThat("testGetMetadata 6",c.getMetadata("provenance_description"), equalTo(""));
|
||||||
assertThat("testGetMetadata 7",c.getMetadata("side_bar_text"), equalTo(""));
|
assertThat("testGetMetadata 7",c.getMetadata("side_bar_text"), equalTo(""));
|
||||||
assertThat("testGetMetadata 8",c.getMetadata("license"), equalTo(""));
|
assertThat("testGetMetadata 8",c.getMetadata("license"), equalTo(""));
|
||||||
@@ -234,12 +232,10 @@ public class CollectionTest extends AbstractDSpaceObjectTest
|
|||||||
* Test of setMetadata method, of class Collection.
|
* Test of setMetadata method, of class Collection.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetMetadata()
|
public void testSetMetadata() throws SQLException {
|
||||||
{
|
|
||||||
String name = "name";
|
String name = "name";
|
||||||
String sdesc = "short description";
|
String sdesc = "short description";
|
||||||
String itext = "introductory text";
|
String itext = "introductory text";
|
||||||
String logo = "1";
|
|
||||||
String copy = "copyright declaration";
|
String copy = "copyright declaration";
|
||||||
String sidebar = "side bar text";
|
String sidebar = "side bar text";
|
||||||
String tempItem = "3";
|
String tempItem = "3";
|
||||||
@@ -249,20 +245,16 @@ public class CollectionTest extends AbstractDSpaceObjectTest
|
|||||||
c.setMetadata("name", name);
|
c.setMetadata("name", name);
|
||||||
c.setMetadata("short_description", sdesc);
|
c.setMetadata("short_description", sdesc);
|
||||||
c.setMetadata("introductory_text", itext);
|
c.setMetadata("introductory_text", itext);
|
||||||
c.setMetadata("logo_bitstream_id", logo);
|
|
||||||
c.setMetadata("copyright_text", copy);
|
c.setMetadata("copyright_text", copy);
|
||||||
c.setMetadata("side_bar_text", sidebar);
|
c.setMetadata("side_bar_text", sidebar);
|
||||||
c.setMetadata("template_item_id", tempItem);
|
|
||||||
c.setMetadata("provenance_description", provDesc);
|
c.setMetadata("provenance_description", provDesc);
|
||||||
c.setMetadata("license", license);
|
c.setMetadata("license", license);
|
||||||
|
|
||||||
assertThat("testSetMetadata 0",c.getMetadata("name"), equalTo(name));
|
assertThat("testSetMetadata 0",c.getMetadata("name"), equalTo(name));
|
||||||
assertThat("testSetMetadata 1",c.getMetadata("short_description"), equalTo(sdesc));
|
assertThat("testSetMetadata 1",c.getMetadata("short_description"), equalTo(sdesc));
|
||||||
assertThat("testSetMetadata 2",c.getMetadata("introductory_text"), equalTo(itext));
|
assertThat("testSetMetadata 2",c.getMetadata("introductory_text"), equalTo(itext));
|
||||||
assertThat("testSetMetadata 3",c.getMetadata("logo_bitstream_id"), equalTo(logo));
|
|
||||||
assertThat("testSetMetadata 4",c.getMetadata("copyright_text"), equalTo(copy));
|
assertThat("testSetMetadata 4",c.getMetadata("copyright_text"), equalTo(copy));
|
||||||
assertThat("testSetMetadata 5",c.getMetadata("side_bar_text"), equalTo(sidebar));
|
assertThat("testSetMetadata 5",c.getMetadata("side_bar_text"), equalTo(sidebar));
|
||||||
assertThat("testGetMetadata 6",c.getMetadata("template_item_id"), equalTo(tempItem));
|
|
||||||
assertThat("testGetMetadata 7",c.getMetadata("provenance_description"), equalTo(provDesc));
|
assertThat("testGetMetadata 7",c.getMetadata("provenance_description"), equalTo(provDesc));
|
||||||
assertThat("testGetMetadata 8",c.getMetadata("license"), equalTo(license));
|
assertThat("testGetMetadata 8",c.getMetadata("license"), equalTo(license));
|
||||||
}
|
}
|
||||||
@@ -689,8 +681,7 @@ public class CollectionTest extends AbstractDSpaceObjectTest
|
|||||||
* Test of setLicense method, of class Collection.
|
* Test of setLicense method, of class Collection.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetLicense()
|
public void testSetLicense() throws SQLException {
|
||||||
{
|
|
||||||
String license = "license for test";
|
String license = "license for test";
|
||||||
c.setLicense(license);
|
c.setLicense(license);
|
||||||
assertThat("testSetLicense 0", c.getLicense(), notNullValue());
|
assertThat("testSetLicense 0", c.getLicense(), notNullValue());
|
||||||
|
@@ -334,7 +334,6 @@ public class CommunityTest extends AbstractDSpaceObjectTest
|
|||||||
assertThat("testGetMetadata 0",c.getMetadata("name"), equalTo(""));
|
assertThat("testGetMetadata 0",c.getMetadata("name"), equalTo(""));
|
||||||
assertThat("testGetMetadata 1",c.getMetadata("short_description"), equalTo(""));
|
assertThat("testGetMetadata 1",c.getMetadata("short_description"), equalTo(""));
|
||||||
assertThat("testGetMetadata 2",c.getMetadata("introductory_text"), equalTo(""));
|
assertThat("testGetMetadata 2",c.getMetadata("introductory_text"), equalTo(""));
|
||||||
assertThat("testGetMetadata 3",c.getMetadata("logo_bitstream_id"), equalTo(""));
|
|
||||||
assertThat("testGetMetadata 4",c.getMetadata("copyright_text"), equalTo(""));
|
assertThat("testGetMetadata 4",c.getMetadata("copyright_text"), equalTo(""));
|
||||||
assertThat("testGetMetadata 5",c.getMetadata("side_bar_text"), equalTo(""));
|
assertThat("testGetMetadata 5",c.getMetadata("side_bar_text"), equalTo(""));
|
||||||
}
|
}
|
||||||
@@ -348,21 +347,18 @@ public class CommunityTest extends AbstractDSpaceObjectTest
|
|||||||
String name = "name";
|
String name = "name";
|
||||||
String sdesc = "short description";
|
String sdesc = "short description";
|
||||||
String itext = "introductory text";
|
String itext = "introductory text";
|
||||||
String logo = "1";
|
|
||||||
String copy = "copyright declaration";
|
String copy = "copyright declaration";
|
||||||
String sidebar = "side bar text";
|
String sidebar = "side bar text";
|
||||||
|
|
||||||
c.setMetadata("name", name);
|
c.setMetadata("name", name);
|
||||||
c.setMetadata("short_description", sdesc);
|
c.setMetadata("short_description", sdesc);
|
||||||
c.setMetadata("introductory_text", itext);
|
c.setMetadata("introductory_text", itext);
|
||||||
c.setMetadata("logo_bitstream_id", logo);
|
|
||||||
c.setMetadata("copyright_text", copy);
|
c.setMetadata("copyright_text", copy);
|
||||||
c.setMetadata("side_bar_text", sidebar);
|
c.setMetadata("side_bar_text", sidebar);
|
||||||
|
|
||||||
assertThat("testSetMetadata 0",c.getMetadata("name"), equalTo(name));
|
assertThat("testSetMetadata 0",c.getMetadata("name"), equalTo(name));
|
||||||
assertThat("testSetMetadata 1",c.getMetadata("short_description"), equalTo(sdesc));
|
assertThat("testSetMetadata 1",c.getMetadata("short_description"), equalTo(sdesc));
|
||||||
assertThat("testSetMetadata 2",c.getMetadata("introductory_text"), equalTo(itext));
|
assertThat("testSetMetadata 2",c.getMetadata("introductory_text"), equalTo(itext));
|
||||||
assertThat("testSetMetadata 3",c.getMetadata("logo_bitstream_id"), equalTo(logo));
|
|
||||||
assertThat("testSetMetadata 4",c.getMetadata("copyright_text"), equalTo(copy));
|
assertThat("testSetMetadata 4",c.getMetadata("copyright_text"), equalTo(copy));
|
||||||
assertThat("testSetMetadata 5",c.getMetadata("side_bar_text"), equalTo(sidebar));
|
assertThat("testSetMetadata 5",c.getMetadata("side_bar_text"), equalTo(sidebar));
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,6 @@ package org.dspace.content;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@@ -294,23 +293,23 @@ public class ItemTest extends AbstractDSpaceObjectTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of getMetadata method, of class Item.
|
* Test of getMetadataByMetadataString method, of class Item.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetMetadata_String()
|
public void testGetMetadata_String()
|
||||||
{
|
{
|
||||||
String mdString = "dc.contributor.author";
|
String mdString = "dc.contributor.author";
|
||||||
DCValue[] dc = it.getMetadata(mdString);
|
DCValue[] dc = it.getMetadataByMetadataString(mdString);
|
||||||
assertThat("testGetMetadata_String 0",dc,notNullValue());
|
assertThat("testGetMetadata_String 0",dc,notNullValue());
|
||||||
assertTrue("testGetMetadata_String 1",dc.length == 0);
|
assertTrue("testGetMetadata_String 1",dc.length == 0);
|
||||||
|
|
||||||
mdString = "dc.contributor.*";
|
mdString = "dc.contributor.*";
|
||||||
dc = it.getMetadata(mdString);
|
dc = it.getMetadataByMetadataString(mdString);
|
||||||
assertThat("testGetMetadata_String 2",dc,notNullValue());
|
assertThat("testGetMetadata_String 2",dc,notNullValue());
|
||||||
assertTrue("testGetMetadata_String 3",dc.length == 0);
|
assertTrue("testGetMetadata_String 3",dc.length == 0);
|
||||||
|
|
||||||
mdString = "dc.contributor";
|
mdString = "dc.contributor";
|
||||||
dc = it.getMetadata(mdString);
|
dc = it.getMetadataByMetadataString(mdString);
|
||||||
assertThat("testGetMetadata_String 4",dc,notNullValue());
|
assertThat("testGetMetadata_String 4",dc,notNullValue());
|
||||||
assertTrue("testGetMetadata_String 5",dc.length == 0);
|
assertTrue("testGetMetadata_String 5",dc.length == 0);
|
||||||
}
|
}
|
||||||
|
@@ -65,11 +65,6 @@ public class MetadataFieldTest extends AbstractUnitTest
|
|||||||
MetadataSchema.DC_SCHEMA_ID, element, qualifier);
|
MetadataSchema.DC_SCHEMA_ID, element, qualifier);
|
||||||
this.mf.setScopeNote(scopeNote);
|
this.mf.setScopeNote(scopeNote);
|
||||||
}
|
}
|
||||||
catch (AuthorizeException ex)
|
|
||||||
{
|
|
||||||
log.error("Authorize Error in init", ex);
|
|
||||||
fail("Authorize Error in init: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
catch (SQLException ex)
|
catch (SQLException ex)
|
||||||
{
|
{
|
||||||
log.error("SQL Error in init", ex);
|
log.error("SQL Error in init", ex);
|
||||||
|
@@ -16,6 +16,7 @@ import java.util.List;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.AbstractIntegrationTest;
|
import org.dspace.AbstractIntegrationTest;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -84,12 +85,14 @@ public class MetadataIntegrationTest extends AbstractIntegrationTest
|
|||||||
field2.create(context);
|
field2.create(context);
|
||||||
|
|
||||||
MetadataValue value1 = new MetadataValue(field1);
|
MetadataValue value1 = new MetadataValue(field1);
|
||||||
value1.setItemId(it.getID());
|
value1.setResourceId(it.getID());
|
||||||
|
value1.setResourceTypeId(Constants.ITEM);
|
||||||
value1.setValue("value1");
|
value1.setValue("value1");
|
||||||
value1.create(context);
|
value1.create(context);
|
||||||
|
|
||||||
MetadataValue value2 = new MetadataValue(field2);
|
MetadataValue value2 = new MetadataValue(field2);
|
||||||
value2.setItemId(it.getID());
|
value2.setResourceId(it.getID());
|
||||||
|
value2.setResourceTypeId(Constants.ITEM);
|
||||||
value2.setValue("value2");
|
value2.setValue("value2");
|
||||||
value2.create(context);
|
value2.create(context);
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@ import java.util.List;
|
|||||||
import org.dspace.AbstractUnitTest;
|
import org.dspace.AbstractUnitTest;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.* ;
|
import static org.junit.Assert.* ;
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
@@ -66,7 +67,8 @@ public class MetadataValueTest extends AbstractUnitTest
|
|||||||
this.mf = MetadataField.findByElement(context,
|
this.mf = MetadataField.findByElement(context,
|
||||||
MetadataSchema.DC_SCHEMA_ID, element, qualifier);
|
MetadataSchema.DC_SCHEMA_ID, element, qualifier);
|
||||||
this.mv = new MetadataValue(mf);
|
this.mv = new MetadataValue(mf);
|
||||||
this.mv.setItemId(Item.create(context).getID());
|
this.mv.setResourceId(Item.create(context).getID());
|
||||||
|
this.mv.setResourceTypeId(Constants.ITEM);
|
||||||
context.commit();
|
context.commit();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
@@ -127,7 +129,7 @@ public class MetadataValueTest extends AbstractUnitTest
|
|||||||
@Test
|
@Test
|
||||||
public void testGetItemId()
|
public void testGetItemId()
|
||||||
{
|
{
|
||||||
assertTrue("testGetItemId 0", mv.getItemId() >= 0);
|
assertTrue("testGetItemId 0", mv.getResourceId() >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,8 +139,9 @@ public class MetadataValueTest extends AbstractUnitTest
|
|||||||
public void testSetItemId()
|
public void testSetItemId()
|
||||||
{
|
{
|
||||||
int itemId = 55;
|
int itemId = 55;
|
||||||
mv.setItemId(itemId);
|
mv.setResourceId(itemId);
|
||||||
assertThat("testSetItemId 0", mv.getItemId(), equalTo(itemId));
|
mv.setResourceTypeId(Constants.ITEM);
|
||||||
|
assertThat("testSetItemId 0", mv.getResourceId(), equalTo(itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -152,13 +152,9 @@ CREATE TABLE Bitstream
|
|||||||
(
|
(
|
||||||
bitstream_id INTEGER PRIMARY KEY,
|
bitstream_id INTEGER PRIMARY KEY,
|
||||||
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
||||||
name VARCHAR(256),
|
|
||||||
size_bytes BIGINT,
|
size_bytes BIGINT,
|
||||||
checksum VARCHAR(64),
|
checksum VARCHAR(64),
|
||||||
checksum_algorithm VARCHAR(32),
|
checksum_algorithm VARCHAR(32),
|
||||||
description TEXT,
|
|
||||||
user_format_description TEXT,
|
|
||||||
source VARCHAR(256),
|
|
||||||
internal_id VARCHAR(256),
|
internal_id VARCHAR(256),
|
||||||
deleted BOOL,
|
deleted BOOL,
|
||||||
store_number INTEGER,
|
store_number INTEGER,
|
||||||
@@ -175,16 +171,11 @@ CREATE TABLE EPerson
|
|||||||
eperson_id INTEGER PRIMARY KEY,
|
eperson_id INTEGER PRIMARY KEY,
|
||||||
email VARCHAR(64),
|
email VARCHAR(64),
|
||||||
password VARCHAR(64),
|
password VARCHAR(64),
|
||||||
firstname VARCHAR(64),
|
|
||||||
lastname VARCHAR(64),
|
|
||||||
can_log_in BOOL,
|
can_log_in BOOL,
|
||||||
require_certificate BOOL,
|
require_certificate BOOL,
|
||||||
self_registered BOOL,
|
self_registered BOOL,
|
||||||
last_active TIMESTAMP,
|
last_active TIMESTAMP,
|
||||||
sub_frequency INTEGER,
|
sub_frequency INTEGER
|
||||||
phone VARCHAR(32),
|
|
||||||
netid VARCHAR(64),
|
|
||||||
language VARCHAR(64)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- index by email
|
-- index by email
|
||||||
@@ -198,8 +189,7 @@ CREATE INDEX eperson_netid_idx ON EPerson(netid);
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
CREATE TABLE EPersonGroup
|
CREATE TABLE EPersonGroup
|
||||||
(
|
(
|
||||||
eperson_group_id INTEGER PRIMARY KEY,
|
eperson_group_id INTEGER PRIMARY KEY
|
||||||
name VARCHAR(256)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
@@ -256,7 +246,6 @@ CREATE INDEX item_submitter_fk_idx ON Item(submitter_id);
|
|||||||
CREATE TABLE Bundle
|
CREATE TABLE Bundle
|
||||||
(
|
(
|
||||||
bundle_id INTEGER PRIMARY KEY,
|
bundle_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR(16),
|
|
||||||
primary_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id)
|
primary_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -315,7 +304,8 @@ CREATE TABLE MetadataFieldRegistry
|
|||||||
CREATE TABLE MetadataValue
|
CREATE TABLE MetadataValue
|
||||||
(
|
(
|
||||||
metadata_value_id INTEGER PRIMARY KEY,
|
metadata_value_id INTEGER PRIMARY KEY,
|
||||||
item_id INTEGER REFERENCES Item(item_id),
|
resource_id INTEGER NOT NULL,
|
||||||
|
resource_type_id INTEGER NOT NULL,
|
||||||
metadata_field_id INTEGER REFERENCES MetadataFieldRegistry(metadata_field_id),
|
metadata_field_id INTEGER REFERENCES MetadataFieldRegistry(metadata_field_id),
|
||||||
text_value TEXT,
|
text_value TEXT,
|
||||||
text_lang VARCHAR(24),
|
text_lang VARCHAR(24),
|
||||||
@@ -326,18 +316,16 @@ CREATE TABLE MetadataValue
|
|||||||
|
|
||||||
-- Create a dcvalue view for backwards compatibilty
|
-- Create a dcvalue view for backwards compatibilty
|
||||||
CREATE VIEW dcvalue AS
|
CREATE VIEW dcvalue AS
|
||||||
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.item_id,
|
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.resource_id,
|
||||||
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
||||||
MetadataValue.text_lang, MetadataValue.place
|
MetadataValue.text_lang, MetadataValue.place
|
||||||
FROM MetadataValue, MetadataFieldRegistry
|
FROM MetadataValue, MetadataFieldRegistry
|
||||||
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
||||||
AND MetadataFieldRegistry.metadata_schema_id = 1;
|
AND MetadataFieldRegistry.metadata_schema_id = 1 AND MetadataValue.resource_type_id = 2;
|
||||||
|
|
||||||
-- An index for item_id - almost all access is based on
|
-- An index for item_id - almost all access is based on
|
||||||
-- instantiating the item object, which grabs all values
|
-- instantiating the item object, which grabs all values
|
||||||
-- related to that item
|
-- related to that item
|
||||||
CREATE INDEX metadatavalue_item_idx ON MetadataValue(item_id);
|
|
||||||
CREATE INDEX metadatavalue_item_idx2 ON MetadataValue(item_id,metadata_field_id);
|
|
||||||
CREATE INDEX metadatavalue_field_fk_idx ON MetadataValue(metadata_field_id);
|
CREATE INDEX metadatavalue_field_fk_idx ON MetadataValue(metadata_field_id);
|
||||||
CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_id);
|
CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_id);
|
||||||
|
|
||||||
@@ -347,12 +335,7 @@ CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_i
|
|||||||
CREATE TABLE Community
|
CREATE TABLE Community
|
||||||
(
|
(
|
||||||
community_id INTEGER PRIMARY KEY,
|
community_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR(128),
|
|
||||||
short_description VARCHAR(512),
|
|
||||||
introductory_text TEXT,
|
|
||||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||||
copyright_text TEXT,
|
|
||||||
side_bar_text TEXT,
|
|
||||||
admin INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
admin INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -365,15 +348,8 @@ CREATE INDEX community_admin_fk_idx ON Community(admin);
|
|||||||
CREATE TABLE Collection
|
CREATE TABLE Collection
|
||||||
(
|
(
|
||||||
collection_id INTEGER PRIMARY KEY,
|
collection_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR(128),
|
|
||||||
short_description VARCHAR(512),
|
|
||||||
introductory_text TEXT,
|
|
||||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||||
template_item_id INTEGER REFERENCES Item(item_id),
|
template_item_id INTEGER REFERENCES Item(item_id),
|
||||||
provenance_description TEXT,
|
|
||||||
license TEXT,
|
|
||||||
copyright_text TEXT,
|
|
||||||
side_bar_text TEXT,
|
|
||||||
workflow_step_1 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_1 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
workflow_step_2 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_2 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
workflow_step_3 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_3 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
@@ -632,8 +608,8 @@ CREATE TABLE community_item_count (
|
|||||||
-- and administrators
|
-- and administrators
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- We don't use getnextid() for 'anonymous' since the sequences start at '1'
|
-- We don't use getnextid() for 'anonymous' since the sequences start at '1'
|
||||||
INSERT INTO epersongroup VALUES(0, 'Anonymous');
|
INSERT INTO epersongroup VALUES(0);
|
||||||
INSERT INTO epersongroup VALUES(NEXTVAL('epersongroup_seq'), 'Administrator');
|
INSERT INTO epersongroup VALUES(NEXTVAL('epersongroup_seq'));
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
@@ -624,12 +624,7 @@ public class BrowseListTag extends TagSupport
|
|||||||
catch (IOException ie)
|
catch (IOException ie)
|
||||||
{
|
{
|
||||||
throw new JspException(ie);
|
throw new JspException(ie);
|
||||||
}
|
} catch (BrowseException e)
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
throw new JspException(e);
|
|
||||||
}
|
|
||||||
catch (BrowseException e)
|
|
||||||
{
|
{
|
||||||
throw new JspException(e);
|
throw new JspException(e);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ public class MetadataStyleSelection extends AKeyBasedStyleSelection
|
|||||||
public String getStyleForItem(Item item) throws SQLException
|
public String getStyleForItem(Item item) throws SQLException
|
||||||
{
|
{
|
||||||
String metadata = ConfigurationManager.getProperty("webui.itemdisplay.metadata-style");
|
String metadata = ConfigurationManager.getProperty("webui.itemdisplay.metadata-style");
|
||||||
DCValue[] value = item.getMetadata(metadata);
|
DCValue[] value = item.getMetadataByMetadataString(metadata);
|
||||||
String styleName = "default";
|
String styleName = "default";
|
||||||
if (value.length > 0)
|
if (value.length > 0)
|
||||||
{
|
{
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
String title = "Unknown Item";
|
String title = "Unknown Item";
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
DCValue[] dcvs = item.getMetadata("dc.title");
|
DCValue[] dcvs = item.getMetadataByMetadataString("dc.title");
|
||||||
if (dcvs != null && dcvs.length > 0)
|
if (dcvs != null && dcvs.length > 0)
|
||||||
{
|
{
|
||||||
title = dcvs[0].value;
|
title = dcvs[0].value;
|
||||||
|
@@ -1188,9 +1188,9 @@
|
|||||||
|
|
||||||
// Fetch the document type (dc.type)
|
// Fetch the document type (dc.type)
|
||||||
String documentType = "";
|
String documentType = "";
|
||||||
if( (item.getMetadata("dc.type") != null) && (item.getMetadata("dc.type").length >0) )
|
if( (item.getMetadataByMetadataString("dc.type") != null) && (item.getMetadataByMetadataString("dc.type").length >0) )
|
||||||
{
|
{
|
||||||
documentType = item.getMetadata("dc.type")[0].value;
|
documentType = item.getMetadataByMetadataString("dc.type")[0].value;
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
String title = "Unknown Item";
|
String title = "Unknown Item";
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
DCValue[] dcvs = item.getMetadata("dc.title");
|
DCValue[] dcvs = item.getMetadataByMetadataString("dc.title");
|
||||||
if (dcvs != null && dcvs.length > 0)
|
if (dcvs != null && dcvs.length > 0)
|
||||||
{
|
{
|
||||||
title = dcvs[0].value;
|
title = dcvs[0].value;
|
||||||
|
@@ -18,6 +18,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.apache.log4j.LogManager;
|
import org.apache.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xoai.data.DSpaceItem;
|
import org.dspace.xoai.data.DSpaceItem;
|
||||||
import org.dspace.xoai.exceptions.InvalidMetadataFieldException;
|
import org.dspace.xoai.exceptions.InvalidMetadataFieldException;
|
||||||
@@ -154,7 +155,7 @@ public class DSpaceAtLeastOneMetadataFilter extends DSpaceFilter {
|
|||||||
for (String v : values)
|
for (String v : values)
|
||||||
this.buildWhere(v, parts, params);
|
this.buildWhere(v, parts, params);
|
||||||
if (parts.size() > 0) {
|
if (parts.size() > 0) {
|
||||||
String query = "EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.item_id=i.item_id AND tmp.metadata_field_id=?"
|
String query = "EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.resource_id=i.item_id AND tmp.resource_type_id=" + Constants.ITEM+ " AND tmp.metadata_field_id=?"
|
||||||
+ " AND ("
|
+ " AND ("
|
||||||
+ StringUtils.join(parts.iterator(), " OR ")
|
+ StringUtils.join(parts.iterator(), " OR ")
|
||||||
+ "))";
|
+ "))";
|
||||||
|
@@ -12,6 +12,7 @@ import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterValue;
|
|||||||
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.SimpleType;
|
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.SimpleType;
|
||||||
import org.apache.log4j.LogManager;
|
import org.apache.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.xoai.data.DSpaceItem;
|
import org.dspace.xoai.data.DSpaceItem;
|
||||||
import org.dspace.xoai.exceptions.InvalidMetadataFieldException;
|
import org.dspace.xoai.exceptions.InvalidMetadataFieldException;
|
||||||
@@ -72,7 +73,7 @@ public class DSpaceMetadataExistsFilter extends DSpaceFilter {
|
|||||||
List<Object> args = new ArrayList<Object>(fields.size());
|
List<Object> args = new ArrayList<Object>(fields.size());
|
||||||
where.append("(");
|
where.append("(");
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
where.append("EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.item_id=i.item_id AND tmp.metadata_field_id=?)");
|
where.append("EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.resource_id=i.item_id AND tmp.resource_type_id=" + Constants.ITEM+ " AND tmp.metadata_field_id=?)");
|
||||||
args.add(fieldResolver.getFieldID(context, fields.get(i)));
|
args.add(fieldResolver.getFieldID(context, fields.get(i)));
|
||||||
|
|
||||||
if (i < fields.size() - 1)
|
if (i < fields.size() - 1)
|
||||||
|
@@ -50,7 +50,7 @@ public class DSpaceSetSpecFilter extends DSpaceFilter
|
|||||||
{
|
{
|
||||||
DSpaceObject dso = handleResolver.resolve(setSpec.replace("col_", ""));
|
DSpaceObject dso = handleResolver.resolve(setSpec.replace("col_", ""));
|
||||||
return new DatabaseFilterResult(
|
return new DatabaseFilterResult(
|
||||||
"EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.item_id=i.item_id AND collection_id = ?)",
|
"EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.resource_id=i.item_id AND collection_id = ?)",
|
||||||
dso.getID());
|
dso.getID());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -66,7 +66,7 @@ public class DSpaceSetSpecFilter extends DSpaceFilter
|
|||||||
List<Integer> list = collectionsService.getAllSubCollections(dso.getID());
|
List<Integer> list = collectionsService.getAllSubCollections(dso.getID());
|
||||||
String subCollections = StringUtils.join(list.iterator(), ",");
|
String subCollections = StringUtils.join(list.iterator(), ",");
|
||||||
return new DatabaseFilterResult(
|
return new DatabaseFilterResult(
|
||||||
"EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.item_id=i.item_id AND collection_id IN ("
|
"EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.resource_id=i.item_id AND collection_id IN ("
|
||||||
+ subCollections + "))");
|
+ subCollections + "))");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@@ -17,6 +17,7 @@ import com.lyncode.xoai.dataprovider.filter.conditions.CustomCondition;
|
|||||||
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterList;
|
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterList;
|
||||||
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterMap;
|
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterMap;
|
||||||
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.StringValue;
|
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.StringValue;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.xoai.filter.DSpaceMetadataExistsFilter;
|
import org.dspace.xoai.filter.DSpaceMetadataExistsFilter;
|
||||||
import org.dspace.xoai.filter.DSpaceSetSpecFilter;
|
import org.dspace.xoai.filter.DSpaceSetSpecFilter;
|
||||||
import org.dspace.xoai.filter.DateFromFilter;
|
import org.dspace.xoai.filter.DateFromFilter;
|
||||||
@@ -116,7 +117,7 @@ public class DSpaceDatabaseQueryResolverTest extends AbstractQueryResolverTest {
|
|||||||
|
|
||||||
DatabaseQuery result = underTest.buildQuery(scopedFilters, START, LENGTH);
|
DatabaseQuery result = underTest.buildQuery(scopedFilters, START, LENGTH);
|
||||||
|
|
||||||
assertThat(result.getQuery(), is("SELECT i.* FROM item i WHERE i.in_archive=true AND ((EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.item_id=i.item_id AND tmp.metadata_field_id=?))) ORDER BY i.item_id OFFSET ? LIMIT ?"));
|
assertThat(result.getQuery(), is("SELECT i.* FROM item i WHERE i.in_archive=true AND ((EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.resource_id=i.item_id AND tmp.resource_type_id=" + Constants.ITEM + " AND tmp.metadata_field_id=?))) ORDER BY i.item_id OFFSET ? LIMIT ?"));
|
||||||
assertThat(((Integer) result.getParameters().get(0)), is(1));
|
assertThat(((Integer) result.getParameters().get(0)), is(1));
|
||||||
assertThat((Integer) result.getParameters().get(1), is(START));
|
assertThat((Integer) result.getParameters().get(1), is(START));
|
||||||
assertThat((Integer) result.getParameters().get(2), is(LENGTH));
|
assertThat((Integer) result.getParameters().get(2), is(LENGTH));
|
||||||
@@ -140,7 +141,7 @@ public class DSpaceDatabaseQueryResolverTest extends AbstractQueryResolverTest {
|
|||||||
|
|
||||||
DatabaseQuery result = underTest.buildQuery(scopedFilters, START, LENGTH);
|
DatabaseQuery result = underTest.buildQuery(scopedFilters, START, LENGTH);
|
||||||
|
|
||||||
assertThat(result.getQuery(), is("SELECT i.* FROM item i WHERE i.in_archive=true AND ((EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.item_id=i.item_id AND tmp.metadata_field_id=?) OR EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.item_id=i.item_id AND tmp.metadata_field_id=?))) ORDER BY i.item_id OFFSET ? LIMIT ?"));
|
assertThat(result.getQuery(), is("SELECT i.* FROM item i WHERE i.in_archive=true AND ((EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.resource_id=i.item_id AND tmp.resource_type_id=" + Constants.ITEM + " AND tmp.metadata_field_id=?) OR EXISTS (SELECT tmp.* FROM metadatavalue tmp WHERE tmp.resource_id=i.item_id AND tmp.resource_type_id=" + Constants.ITEM + " AND tmp.metadata_field_id=?))) ORDER BY i.item_id OFFSET ? LIMIT ?"));
|
||||||
assertThat(((Integer) result.getParameters().get(0)), is(1));
|
assertThat(((Integer) result.getParameters().get(0)), is(1));
|
||||||
assertThat(((Integer) result.getParameters().get(1)), is(2));
|
assertThat(((Integer) result.getParameters().get(1)), is(2));
|
||||||
assertThat((Integer) result.getParameters().get(2), is(START));
|
assertThat((Integer) result.getParameters().get(2), is(START));
|
||||||
|
@@ -54,7 +54,7 @@ public class ItemCollectionGenerator extends ATOMCollectionGenerator
|
|||||||
|
|
||||||
// the item title is the sword collection title, or "untitled" otherwise
|
// the item title is the sword collection title, or "untitled" otherwise
|
||||||
String title = "Untitled";
|
String title = "Untitled";
|
||||||
DCValue[] dcv = item.getMetadata("dc.title");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.title");
|
||||||
if (dcv.length > 0)
|
if (dcv.length > 0)
|
||||||
{
|
{
|
||||||
title = dcv[0].value;
|
title = dcv[0].value;
|
||||||
@@ -67,7 +67,7 @@ public class ItemCollectionGenerator extends ATOMCollectionGenerator
|
|||||||
|
|
||||||
// abstract is the short description of the item, if it exists
|
// abstract is the short description of the item, if it exists
|
||||||
String dcAbstract = "";
|
String dcAbstract = "";
|
||||||
DCValue[] dcva = item.getMetadata("dc.description.abstract");
|
DCValue[] dcva = item.getMetadataByMetadataString("dc.description.abstract");
|
||||||
if (dcva.length > 0)
|
if (dcva.length > 0)
|
||||||
{
|
{
|
||||||
dcAbstract = dcva[0].value;
|
dcAbstract = dcva[0].value;
|
||||||
|
@@ -47,7 +47,7 @@ public class ItemEntryGenerator extends DSpaceATOMEntry
|
|||||||
*/
|
*/
|
||||||
protected void addCategories()
|
protected void addCategories()
|
||||||
{
|
{
|
||||||
DCValue[] dcv = item.getMetadata("dc.subject.*");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.subject.*");
|
||||||
if (dcv != null)
|
if (dcv != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < dcv.length; i++)
|
for (int i = 0; i < dcv.length; i++)
|
||||||
@@ -233,7 +233,7 @@ public class ItemEntryGenerator extends DSpaceATOMEntry
|
|||||||
*/
|
*/
|
||||||
protected void addPublishDate()
|
protected void addPublishDate()
|
||||||
{
|
{
|
||||||
DCValue[] dcv = item.getMetadata("dc.date.issued");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.date.issued");
|
||||||
if (dcv != null && dcv.length == 1)
|
if (dcv != null && dcv.length == 1)
|
||||||
{
|
{
|
||||||
entry.setPublished(dcv[0].value);
|
entry.setPublished(dcv[0].value);
|
||||||
@@ -298,7 +298,7 @@ public class ItemEntryGenerator extends DSpaceATOMEntry
|
|||||||
*/
|
*/
|
||||||
protected void addSummary()
|
protected void addSummary()
|
||||||
{
|
{
|
||||||
DCValue[] dcv = item.getMetadata("dc.description.abstract");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.description.abstract");
|
||||||
if (dcv != null)
|
if (dcv != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < dcv.length; i++)
|
for (int i = 0; i < dcv.length; i++)
|
||||||
@@ -317,7 +317,7 @@ public class ItemEntryGenerator extends DSpaceATOMEntry
|
|||||||
*/
|
*/
|
||||||
protected void addTitle()
|
protected void addTitle()
|
||||||
{
|
{
|
||||||
DCValue[] dcv = item.getMetadata("dc.title");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.title");
|
||||||
if (dcv != null)
|
if (dcv != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < dcv.length; i++)
|
for (int i = 0; i < dcv.length; i++)
|
||||||
@@ -337,7 +337,7 @@ public class ItemEntryGenerator extends DSpaceATOMEntry
|
|||||||
protected void addLastUpdatedDate()
|
protected void addLastUpdatedDate()
|
||||||
{
|
{
|
||||||
String config = ConfigurationManager.getProperty("sword-server", "updated.field");
|
String config = ConfigurationManager.getProperty("sword-server", "updated.field");
|
||||||
DCValue[] dcv = item.getMetadata(config);
|
DCValue[] dcv = item.getMetadataByMetadataString(config);
|
||||||
if (dcv != null && dcv.length == 1)
|
if (dcv != null && dcv.length == 1)
|
||||||
{
|
{
|
||||||
DCDate dcd = new DCDate(dcv[0].value);
|
DCDate dcd = new DCDate(dcv[0].value);
|
||||||
|
@@ -43,7 +43,7 @@ public class AtomStatementDisseminator extends GenericStatementDisseminator impl
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCValue[] dcvs = item.getMetadata(field);
|
DCValue[] dcvs = item.getMetadataByMetadataString(field);
|
||||||
if (dcvs == null || dcvs.length == 0)
|
if (dcvs == null || dcvs.length == 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@@ -180,7 +180,7 @@ public class CollectionListManagerDSpace extends DSpaceSwordAPI implements Colle
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCValue[] dcvs = item.getMetadata(field);
|
DCValue[] dcvs = item.getMetadataByMetadataString(field);
|
||||||
if (dcvs == null)
|
if (dcvs == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@@ -222,7 +222,7 @@ public class ReceiptGenerator
|
|||||||
*/
|
*/
|
||||||
protected void addCategories(DepositResult result, DepositReceipt receipt)
|
protected void addCategories(DepositResult result, DepositReceipt receipt)
|
||||||
{
|
{
|
||||||
DCValue[] dcv = result.getItem().getMetadata("dc.subject.*");
|
DCValue[] dcv = result.getItem().getMetadataByMetadataString("dc.subject.*");
|
||||||
if (dcv != null)
|
if (dcv != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < dcv.length; i++)
|
for (int i = 0; i < dcv.length; i++)
|
||||||
@@ -234,7 +234,7 @@ public class ReceiptGenerator
|
|||||||
|
|
||||||
protected void addCategories(Item item, DepositReceipt receipt)
|
protected void addCategories(Item item, DepositReceipt receipt)
|
||||||
{
|
{
|
||||||
DCValue[] dcv = item.getMetadata("dc.subject.*");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.subject.*");
|
||||||
if (dcv != null)
|
if (dcv != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < dcv.length; i++)
|
for (int i = 0; i < dcv.length; i++)
|
||||||
@@ -250,7 +250,7 @@ public class ReceiptGenerator
|
|||||||
*/
|
*/
|
||||||
protected void addPublishDate(DepositResult result, DepositReceipt receipt)
|
protected void addPublishDate(DepositResult result, DepositReceipt receipt)
|
||||||
{
|
{
|
||||||
DCValue[] dcv = result.getItem().getMetadata("dc.date.issued");
|
DCValue[] dcv = result.getItem().getMetadataByMetadataString("dc.date.issued");
|
||||||
if (dcv != null && dcv.length == 1)
|
if (dcv != null && dcv.length == 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -269,7 +269,7 @@ public class ReceiptGenerator
|
|||||||
|
|
||||||
protected void addPublishDate(Item item, DepositReceipt receipt)
|
protected void addPublishDate(Item item, DepositReceipt receipt)
|
||||||
{
|
{
|
||||||
DCValue[] dcv = item.getMetadata("dc.date.issued");
|
DCValue[] dcv = item.getMetadataByMetadataString("dc.date.issued");
|
||||||
if (dcv != null && dcv.length == 1)
|
if (dcv != null && dcv.length == 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -293,7 +293,7 @@ public class ReceiptGenerator
|
|||||||
protected void addLastUpdatedDate(DepositResult result, DepositReceipt receipt)
|
protected void addLastUpdatedDate(DepositResult result, DepositReceipt receipt)
|
||||||
{
|
{
|
||||||
String config = ConfigurationManager.getProperty("swordv2-server", "updated.field");
|
String config = ConfigurationManager.getProperty("swordv2-server", "updated.field");
|
||||||
DCValue[] dcv = result.getItem().getMetadata(config);
|
DCValue[] dcv = result.getItem().getMetadataByMetadataString(config);
|
||||||
if (dcv != null && dcv.length == 1)
|
if (dcv != null && dcv.length == 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -313,7 +313,7 @@ public class ReceiptGenerator
|
|||||||
protected void addLastUpdatedDate(Item item, DepositReceipt receipt)
|
protected void addLastUpdatedDate(Item item, DepositReceipt receipt)
|
||||||
{
|
{
|
||||||
String config = ConfigurationManager.getProperty("swordv2-server", "updated.field");
|
String config = ConfigurationManager.getProperty("swordv2-server", "updated.field");
|
||||||
DCValue[] dcv = item.getMetadata(config);
|
DCValue[] dcv = item.getMetadataByMetadataString(config);
|
||||||
if (dcv != null && dcv.length == 1)
|
if (dcv != null && dcv.length == 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@@ -26,7 +26,6 @@ import org.dspace.content.DCValue;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.storage.rdbms.TableRow;
|
|
||||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
|
|
||||||
@@ -189,9 +188,9 @@ public class CSVOutputter extends AbstractReader implements Recyclable
|
|||||||
entryValues[2] = bitstream.getBundles()[0].getName();
|
entryValues[2] = bitstream.getBundles()[0].getName();
|
||||||
entryValues[3] = item.getName();
|
entryValues[3] = item.getName();
|
||||||
entryValues[4] = "http://hdl.handle.net/" + item.getHandle();
|
entryValues[4] = "http://hdl.handle.net/" + item.getHandle();
|
||||||
entryValues[5] = wrapInDelimitedString(item.getMetadata("dc.creator"));
|
entryValues[5] = wrapInDelimitedString(item.getMetadataByMetadataString("dc.creator"));
|
||||||
entryValues[6] = wrapInDelimitedString(item.getMetadata("dc.publisher"));
|
entryValues[6] = wrapInDelimitedString(item.getMetadataByMetadataString("dc.publisher"));
|
||||||
entryValues[7] = wrapInDelimitedString(item.getMetadata("dc.date.issued"));
|
entryValues[7] = wrapInDelimitedString(item.getMetadataByMetadataString("dc.date.issued"));
|
||||||
entryValues[8] = facetEntry.getCount() + "";
|
entryValues[8] = facetEntry.getCount() + "";
|
||||||
writer.writeNext(entryValues);
|
writer.writeNext(entryValues);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -409,7 +409,7 @@ public class ElasticSearchStatsViewer extends AbstractDSpaceTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getFirstMetadataValue(Item item, String metadataKey) {
|
private String getFirstMetadataValue(Item item, String metadataKey) {
|
||||||
DCValue[] dcValue = item.getMetadata(metadataKey);
|
DCValue[] dcValue = item.getMetadataByMetadataString(metadataKey);
|
||||||
if(dcValue.length > 0) {
|
if(dcValue.length > 0) {
|
||||||
return dcValue[0].value;
|
return dcValue[0].value;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -181,9 +181,9 @@ public class DescribeStep extends AbstractSubmissionStep
|
|||||||
|
|
||||||
// Fetch the document type (dc.type)
|
// Fetch the document type (dc.type)
|
||||||
String documentType = "";
|
String documentType = "";
|
||||||
if( (item.getMetadata("dc.type") != null) && (item.getMetadata("dc.type").length >0) )
|
if( (item.getMetadataByMetadataString("dc.type") != null) && (item.getMetadataByMetadataString("dc.type").length >0) )
|
||||||
{
|
{
|
||||||
documentType = item.getMetadata("dc.type")[0].value;
|
documentType = item.getMetadataByMetadataString("dc.type")[0].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over all inputs and add it to the form.
|
// Iterate over all inputs and add it to the form.
|
||||||
|
@@ -25,8 +25,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabio Bolognesi (fabio at atmire dot com)
|
* @author Fabio Bolognesi (fabio at atmire dot com)
|
||||||
@@ -133,7 +131,7 @@ public class BibTexView implements View {
|
|||||||
|
|
||||||
private String getMetadataValue(Item item, String metadatafield)
|
private String getMetadataValue(Item item, String metadatafield)
|
||||||
{
|
{
|
||||||
for (DCValue value : item.getMetadata(metadatafield))
|
for (DCValue value : item.getMetadataByMetadataString(metadatafield))
|
||||||
{
|
{
|
||||||
return value.value;
|
return value.value;
|
||||||
}
|
}
|
||||||
@@ -145,16 +143,16 @@ public class BibTexView implements View {
|
|||||||
{
|
{
|
||||||
ArrayList<String> authors = new ArrayList<String>();
|
ArrayList<String> authors = new ArrayList<String>();
|
||||||
|
|
||||||
authors.addAll(getAuthors(aItem.getMetadata("dc.contributor.author")));
|
authors.addAll(getAuthors(aItem.getMetadataByMetadataString("dc.contributor.author")));
|
||||||
authors.addAll(getAuthors(aItem.getMetadata("dc.creator")));
|
authors.addAll(getAuthors(aItem.getMetadataByMetadataString("dc.creator")));
|
||||||
authors.addAll(getAuthors(aItem.getMetadata("dc.contributor")));
|
authors.addAll(getAuthors(aItem.getMetadataByMetadataString("dc.contributor")));
|
||||||
|
|
||||||
return authors.toArray(new String[authors.size()]);
|
return authors.toArray(new String[authors.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getYear(Item aItem)
|
private String getYear(Item aItem)
|
||||||
{
|
{
|
||||||
for (DCValue date : aItem.getMetadata("dc.date.issued"))
|
for (DCValue date : aItem.getMetadataByMetadataString("dc.date.issued"))
|
||||||
{
|
{
|
||||||
return date.value.substring(0, 4);
|
return date.value.substring(0, 4);
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,6 @@ import org.dspace.content.DCValue;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.identifier.IdentifierService;
|
|
||||||
import org.dspace.utils.DSpace;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.servlet.View;
|
import org.springframework.web.servlet.View;
|
||||||
@@ -28,8 +26,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabio Bolognesi (fabio at atmire dot com)
|
* @author Fabio Bolognesi (fabio at atmire dot com)
|
||||||
@@ -159,9 +155,9 @@ public class RisView implements View {
|
|||||||
{
|
{
|
||||||
ArrayList<String> authors = new ArrayList<String>();
|
ArrayList<String> authors = new ArrayList<String>();
|
||||||
|
|
||||||
authors.addAll(getAuthors(aItem.getMetadata("dc.contributor.author")));
|
authors.addAll(getAuthors(aItem.getMetadataByMetadataString("dc.contributor.author")));
|
||||||
authors.addAll(getAuthors(aItem.getMetadata("dc.creator")));
|
authors.addAll(getAuthors(aItem.getMetadataByMetadataString("dc.creator")));
|
||||||
authors.addAll(getAuthors(aItem.getMetadata("dc.contributor")));
|
authors.addAll(getAuthors(aItem.getMetadataByMetadataString("dc.contributor")));
|
||||||
|
|
||||||
return authors.toArray(new String[authors.size()]);
|
return authors.toArray(new String[authors.size()]);
|
||||||
}
|
}
|
||||||
@@ -170,7 +166,7 @@ public class RisView implements View {
|
|||||||
{
|
{
|
||||||
ArrayList<String> keywordList = new ArrayList<String>();
|
ArrayList<String> keywordList = new ArrayList<String>();
|
||||||
|
|
||||||
for (DCValue keyword : aItem.getMetadata("dc.subject"))
|
for (DCValue keyword : aItem.getMetadataByMetadataString("dc.subject"))
|
||||||
{
|
{
|
||||||
if (keyword.value.length() < 255)
|
if (keyword.value.length() < 255)
|
||||||
{
|
{
|
||||||
@@ -178,7 +174,7 @@ public class RisView implements View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DCValue keyword : aItem.getMetadata("dwc.ScientificName"))
|
for (DCValue keyword : aItem.getMetadataByMetadataString("dwc.ScientificName"))
|
||||||
{
|
{
|
||||||
if (keyword.value.length() < 255)
|
if (keyword.value.length() < 255)
|
||||||
{
|
{
|
||||||
@@ -193,7 +189,7 @@ public class RisView implements View {
|
|||||||
{
|
{
|
||||||
StringTokenizer tokenizer;
|
StringTokenizer tokenizer;
|
||||||
|
|
||||||
for (DCValue date : item.getMetadata("dc.date.issued"))
|
for (DCValue date : item.getMetadataByMetadataString("dc.date.issued"))
|
||||||
{
|
{
|
||||||
tokenizer = new StringTokenizer(date.value, "-/ T");
|
tokenizer = new StringTokenizer(date.value, "-/ T");
|
||||||
String[] dateParts = new String[tokenizer.countTokens()];
|
String[] dateParts = new String[tokenizer.countTokens()];
|
||||||
@@ -211,7 +207,7 @@ public class RisView implements View {
|
|||||||
|
|
||||||
private String getMetadataValue(Item item, String metadatafield)
|
private String getMetadataValue(Item item, String metadatafield)
|
||||||
{
|
{
|
||||||
for (DCValue value : item.getMetadata(metadatafield))
|
for (DCValue value : item.getMetadataByMetadataString(metadatafield))
|
||||||
{
|
{
|
||||||
return value.value;
|
return value.value;
|
||||||
}
|
}
|
||||||
|
@@ -584,4 +584,18 @@
|
|||||||
<scope_note>Nature or genre of content.</scope_note>
|
<scope_note>Nature or genre of content.</scope_note>
|
||||||
</dc-type>
|
</dc-type>
|
||||||
|
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>dc</schema>
|
||||||
|
<element>provenance</element>
|
||||||
|
<!-- unqualified -->
|
||||||
|
<scope_note></scope_note>
|
||||||
|
</dc-type>
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>dc</schema>
|
||||||
|
<element>rights</element>
|
||||||
|
<qualifier>license</qualifier>
|
||||||
|
<scope_note></scope_note>
|
||||||
|
</dc-type>
|
||||||
</dspace-dc-types>
|
</dspace-dc-types>
|
||||||
|
47
dspace/config/registries/eperson-types.xml
Normal file
47
dspace/config/registries/eperson-types.xml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<dspace-dc-types>
|
||||||
|
|
||||||
|
<dspace-header>
|
||||||
|
<title>DSpace EPerson</title>
|
||||||
|
<contributor.author>Kevin Van de Velde</contributor.author>
|
||||||
|
<contributor.author>Bert Vanderhallen</contributor.author>
|
||||||
|
<contributor.author>Ben Bosman</contributor.author>
|
||||||
|
<contributor.author>Mark Diggory</contributor.author>
|
||||||
|
</dspace-header>
|
||||||
|
|
||||||
|
<dc-schema>
|
||||||
|
<name>eperson</name>
|
||||||
|
<namespace>http://dspace.org/eperson</namespace>
|
||||||
|
</dc-schema>
|
||||||
|
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>eperson</schema>
|
||||||
|
<element>firstname</element>
|
||||||
|
<scope_note>Metadata field used for the first name</scope_note>
|
||||||
|
</dc-type>
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>eperson</schema>
|
||||||
|
<element>lastname</element>
|
||||||
|
<scope_note>Metadata field used for the last name</scope_note>
|
||||||
|
</dc-type>
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>eperson</schema>
|
||||||
|
<element>phone</element>
|
||||||
|
<scope_note>Metadata field used for the phone number</scope_note>
|
||||||
|
</dc-type>
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>eperson</schema>
|
||||||
|
<element>netid</element>
|
||||||
|
<scope_note>Metadata field used for the net id</scope_note>
|
||||||
|
</dc-type>
|
||||||
|
|
||||||
|
<dc-type>
|
||||||
|
<schema>eperson</schema>
|
||||||
|
<element>language</element>
|
||||||
|
<scope_note>Metadata field used for the language</scope_note>
|
||||||
|
</dc-type>
|
||||||
|
|
||||||
|
</dspace-dc-types>
|
@@ -109,13 +109,9 @@ CREATE TABLE Bitstream
|
|||||||
(
|
(
|
||||||
bitstream_id INTEGER PRIMARY KEY,
|
bitstream_id INTEGER PRIMARY KEY,
|
||||||
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
||||||
name VARCHAR2(256),
|
|
||||||
size_bytes INTEGER,
|
size_bytes INTEGER,
|
||||||
checksum VARCHAR2(64),
|
checksum VARCHAR2(64),
|
||||||
checksum_algorithm VARCHAR2(32),
|
checksum_algorithm VARCHAR2(32),
|
||||||
description VARCHAR2(2000),
|
|
||||||
user_format_description VARCHAR2(2000),
|
|
||||||
source VARCHAR2(256),
|
|
||||||
internal_id VARCHAR2(256),
|
internal_id VARCHAR2(256),
|
||||||
deleted NUMBER(1),
|
deleted NUMBER(1),
|
||||||
store_number INTEGER,
|
store_number INTEGER,
|
||||||
@@ -134,16 +130,11 @@ CREATE TABLE EPerson
|
|||||||
password VARCHAR2(128),
|
password VARCHAR2(128),
|
||||||
salt VARCHAR2(32),
|
salt VARCHAR2(32),
|
||||||
digest_algorithm VARCHAR2(16),
|
digest_algorithm VARCHAR2(16),
|
||||||
firstname VARCHAR2(64),
|
|
||||||
lastname VARCHAR2(64),
|
|
||||||
can_log_in NUMBER(1),
|
can_log_in NUMBER(1),
|
||||||
require_certificate NUMBER(1),
|
require_certificate NUMBER(1),
|
||||||
self_registered NUMBER(1),
|
self_registered NUMBER(1),
|
||||||
last_active TIMESTAMP,
|
last_active TIMESTAMP,
|
||||||
sub_frequency INTEGER,
|
sub_frequency INTEGER
|
||||||
phone VARCHAR2(32),
|
|
||||||
netid VARCHAR2(64) UNIQUE,
|
|
||||||
language VARCHAR2(64)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
@@ -151,8 +142,7 @@ CREATE TABLE EPerson
|
|||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
CREATE TABLE EPersonGroup
|
CREATE TABLE EPersonGroup
|
||||||
(
|
(
|
||||||
eperson_group_id INTEGER PRIMARY KEY,
|
eperson_group_id INTEGER PRIMARY KEY
|
||||||
name VARCHAR2(256) UNIQUE
|
|
||||||
);
|
);
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
@@ -269,7 +259,8 @@ CREATE TABLE MetadataFieldRegistry
|
|||||||
CREATE TABLE MetadataValue
|
CREATE TABLE MetadataValue
|
||||||
(
|
(
|
||||||
metadata_value_id INTEGER PRIMARY KEY,
|
metadata_value_id INTEGER PRIMARY KEY,
|
||||||
item_id INTEGER REFERENCES Item(item_id),
|
resource_id INTEGER NOT NULL,
|
||||||
|
resource_type_id INTEGER NOT NULL,
|
||||||
metadata_field_id INTEGER REFERENCES MetadataFieldRegistry(metadata_field_id),
|
metadata_field_id INTEGER REFERENCES MetadataFieldRegistry(metadata_field_id),
|
||||||
text_value CLOB,
|
text_value CLOB,
|
||||||
text_lang VARCHAR(24),
|
text_lang VARCHAR(24),
|
||||||
@@ -283,18 +274,16 @@ INSERT INTO MetadataSchemaRegistry VALUES (1,'http://dublincore.org/documents/dc
|
|||||||
|
|
||||||
-- Create a dcvalue view for backwards compatibilty
|
-- Create a dcvalue view for backwards compatibilty
|
||||||
CREATE VIEW dcvalue AS
|
CREATE VIEW dcvalue AS
|
||||||
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.item_id,
|
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.resource_id,
|
||||||
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
||||||
MetadataValue.text_lang, MetadataValue.place
|
MetadataValue.text_lang, MetadataValue.place
|
||||||
FROM MetadataValue, MetadataFieldRegistry
|
FROM MetadataValue, MetadataFieldRegistry
|
||||||
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
||||||
AND MetadataFieldRegistry.metadata_schema_id = 1;
|
AND MetadataFieldRegistry.metadata_schema_id = 1 AND MetadataValue.resource_type_id = 2;
|
||||||
|
|
||||||
-- An index for item_id - almost all access is based on
|
-- An index for item_id - almost all access is based on
|
||||||
-- instantiating the item object, which grabs all values
|
-- instantiating the item object, which grabs all values
|
||||||
-- related to that item
|
-- related to that item
|
||||||
CREATE INDEX metadatavalue_item_idx ON MetadataValue(item_id);
|
|
||||||
CREATE INDEX metadatavalue_item_idx2 ON MetadataValue(item_id,metadata_field_id);
|
|
||||||
CREATE INDEX metadatavalue_field_fk_idx ON MetadataValue(metadata_field_id);
|
CREATE INDEX metadatavalue_field_fk_idx ON MetadataValue(metadata_field_id);
|
||||||
CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_id);
|
CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_id);
|
||||||
|
|
||||||
@@ -304,12 +293,7 @@ CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_i
|
|||||||
CREATE TABLE Community
|
CREATE TABLE Community
|
||||||
(
|
(
|
||||||
community_id INTEGER PRIMARY KEY,
|
community_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR2(128),
|
|
||||||
short_description VARCHAR2(512),
|
|
||||||
introductory_text CLOB,
|
|
||||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||||
copyright_text CLOB,
|
|
||||||
side_bar_text VARCHAR2(2000),
|
|
||||||
admin INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
admin INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -322,15 +306,8 @@ CREATE INDEX community_admin_fk_idx ON Community(admin);
|
|||||||
CREATE TABLE Collection
|
CREATE TABLE Collection
|
||||||
(
|
(
|
||||||
collection_id INTEGER PRIMARY KEY,
|
collection_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR2(128),
|
|
||||||
short_description VARCHAR2(512),
|
|
||||||
introductory_text CLOB,
|
|
||||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||||
template_item_id INTEGER REFERENCES Item(item_id),
|
template_item_id INTEGER REFERENCES Item(item_id),
|
||||||
provenance_description VARCHAR2(2000),
|
|
||||||
license CLOB,
|
|
||||||
copyright_text CLOB,
|
|
||||||
side_bar_text VARCHAR2(2000),
|
|
||||||
workflow_step_1 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_1 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
workflow_step_2 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_2 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
workflow_step_3 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_3 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
@@ -600,8 +577,8 @@ CREATE TABLE community_item_count (
|
|||||||
-- and administrators
|
-- and administrators
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- We don't use getnextid() for 'anonymous' since the sequences start at '1'
|
-- We don't use getnextid() for 'anonymous' since the sequences start at '1'
|
||||||
INSERT INTO epersongroup VALUES(0, 'Anonymous');
|
INSERT INTO epersongroup VALUES(0);
|
||||||
INSERT INTO epersongroup VALUES(1, 'Administrator');
|
INSERT INTO epersongroup VALUES(1);
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
@@ -12,3 +12,349 @@
|
|||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
ALTER TABLE requestitem ADD request_message VARCHAR2(2000);
|
ALTER TABLE requestitem ADD request_message VARCHAR2(2000);
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE
|
||||||
|
statement VARCHAR2(2000);
|
||||||
|
constr_name VARCHAR2(300);
|
||||||
|
BEGIN
|
||||||
|
SELECT CONSTRAINT_NAME INTO constr_name
|
||||||
|
FROM USER_CONS_COLUMNS
|
||||||
|
WHERE table_name = 'METADATAVALUE' AND COLUMN_NAME='ITEM_ID';
|
||||||
|
statement := 'ALTER TABLE METADATAVALUE DROP CONSTRAINT '|| constr_name;
|
||||||
|
EXECUTE IMMEDIATE(statement);
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
|
alter table metadatavalue rename column item_id to resource_id;
|
||||||
|
|
||||||
|
alter table metadatavalue MODIFY(resource_id not null);
|
||||||
|
alter table metadatavalue add resource_type_id integer;
|
||||||
|
UPDATE metadatavalue SET resource_type_id = 2;
|
||||||
|
alter table metadatavalue MODIFY(resource_type_id not null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- community
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier is null) AS metadata_field_id,
|
||||||
|
introductory_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not introductory_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'abstract') AS metadata_field_id,
|
||||||
|
short_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not short_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'tableofcontents') AS metadata_field_id,
|
||||||
|
side_bar_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not side_bar_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'rights' and qualifier is null) AS metadata_field_id,
|
||||||
|
copyright_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not copyright_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not name is null;
|
||||||
|
|
||||||
|
alter table community drop (introductory_text, short_description, side_bar_text, copyright_text, name);
|
||||||
|
|
||||||
|
|
||||||
|
-- ----------
|
||||||
|
-- collection
|
||||||
|
-- ----------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier is null) AS metadata_field_id,
|
||||||
|
introductory_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not introductory_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'abstract') AS metadata_field_id,
|
||||||
|
short_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not short_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'tableofcontents') AS metadata_field_id,
|
||||||
|
side_bar_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not side_bar_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'rights' and qualifier is null) AS metadata_field_id,
|
||||||
|
copyright_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not copyright_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not name is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'provenance' and qualifier is null) AS metadata_field_id,
|
||||||
|
provenance_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not provenance_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'rights' and qualifier = 'license') AS metadata_field_id,
|
||||||
|
license AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not license is null;
|
||||||
|
|
||||||
|
alter table collection drop (introductory_text, short_description, copyright_text, side_bar_text, name, license, provenance_description);
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- bundle
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
bundle_id AS resource_id,
|
||||||
|
1 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bundle where not name is null;
|
||||||
|
|
||||||
|
alter table bundle drop column name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- bitstream
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not name is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier is null) AS metadata_field_id,
|
||||||
|
description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'format' and qualifier is null) AS metadata_field_id,
|
||||||
|
user_format_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not user_format_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'source' and qualifier is null) AS metadata_field_id,
|
||||||
|
source AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not source is null;
|
||||||
|
|
||||||
|
alter table bitstream drop (name, description, user_format_description, source);
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- epersongroup
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_group_id AS resource_id,
|
||||||
|
6 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM epersongroup where not name is null;
|
||||||
|
|
||||||
|
alter table epersongroup drop column name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- eperson
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'email' and qualifier is null) AS metadata_field_id,
|
||||||
|
email AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not email is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'firstname' and qualifier is null) AS metadata_field_id,
|
||||||
|
firstname AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not firstname is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'lastname' and qualifier is null) AS metadata_field_id,
|
||||||
|
lastname AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not lastname is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'phone' and qualifier is null) AS metadata_field_id,
|
||||||
|
phone AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not phone is null;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'netid' and qualifier is null) AS metadata_field_id,
|
||||||
|
netid AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not netid is null;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (metadata_value_id, resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
metadatavalue_seq.nextval as metadata_value_id,
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'language' and qualifier is null) AS metadata_field_id,
|
||||||
|
language AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not language is null;
|
||||||
|
|
||||||
|
|
||||||
|
alter table eperson drop (firstname, lastname, phone, netid, language);
|
||||||
|
|
||||||
|
drop view dcvalue;
|
||||||
|
|
||||||
|
CREATE VIEW dcvalue AS
|
||||||
|
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.resource_id,
|
||||||
|
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
||||||
|
MetadataValue.text_lang, MetadataValue.place
|
||||||
|
FROM MetadataValue, MetadataFieldRegistry
|
||||||
|
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
||||||
|
AND MetadataFieldRegistry.metadata_schema_id = 1 AND MetadataValue.resource_type_id = 2;
|
||||||
|
@@ -146,13 +146,9 @@ CREATE TABLE Bitstream
|
|||||||
(
|
(
|
||||||
bitstream_id INTEGER PRIMARY KEY,
|
bitstream_id INTEGER PRIMARY KEY,
|
||||||
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
bitstream_format_id INTEGER REFERENCES BitstreamFormatRegistry(bitstream_format_id),
|
||||||
name VARCHAR(256),
|
|
||||||
size_bytes BIGINT,
|
size_bytes BIGINT,
|
||||||
checksum VARCHAR(64),
|
checksum VARCHAR(64),
|
||||||
checksum_algorithm VARCHAR(32),
|
checksum_algorithm VARCHAR(32),
|
||||||
description TEXT,
|
|
||||||
user_format_description TEXT,
|
|
||||||
source VARCHAR(256),
|
|
||||||
internal_id VARCHAR(256),
|
internal_id VARCHAR(256),
|
||||||
deleted BOOL,
|
deleted BOOL,
|
||||||
store_number INTEGER,
|
store_number INTEGER,
|
||||||
@@ -171,31 +167,25 @@ CREATE TABLE EPerson
|
|||||||
password VARCHAR(128),
|
password VARCHAR(128),
|
||||||
salt VARCHAR(32),
|
salt VARCHAR(32),
|
||||||
digest_algorithm VARCHAR(16),
|
digest_algorithm VARCHAR(16),
|
||||||
firstname VARCHAR(64),
|
|
||||||
lastname VARCHAR(64),
|
|
||||||
can_log_in BOOL,
|
can_log_in BOOL,
|
||||||
require_certificate BOOL,
|
require_certificate BOOL,
|
||||||
self_registered BOOL,
|
self_registered BOOL,
|
||||||
last_active TIMESTAMP,
|
last_active TIMESTAMP,
|
||||||
sub_frequency INTEGER,
|
sub_frequency INTEGER
|
||||||
phone VARCHAR(32),
|
|
||||||
netid VARCHAR(64),
|
|
||||||
language VARCHAR(64)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- index by email
|
-- index by email
|
||||||
CREATE INDEX eperson_email_idx ON EPerson(email);
|
CREATE INDEX eperson_email_idx ON EPerson(email);
|
||||||
|
|
||||||
-- index by netid
|
-- index by netid
|
||||||
CREATE INDEX eperson_netid_idx ON EPerson(netid);
|
--CREATE INDEX eperson_netid_idx ON EPerson(netid);
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- EPersonGroup table
|
-- EPersonGroup table
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
CREATE TABLE EPersonGroup
|
CREATE TABLE EPersonGroup
|
||||||
(
|
(
|
||||||
eperson_group_id INTEGER PRIMARY KEY,
|
eperson_group_id INTEGER PRIMARY KEY
|
||||||
name VARCHAR(256) UNIQUE
|
|
||||||
);
|
);
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
@@ -312,7 +302,8 @@ CREATE TABLE MetadataFieldRegistry
|
|||||||
CREATE TABLE MetadataValue
|
CREATE TABLE MetadataValue
|
||||||
(
|
(
|
||||||
metadata_value_id INTEGER PRIMARY KEY DEFAULT NEXTVAL('metadatavalue_seq'),
|
metadata_value_id INTEGER PRIMARY KEY DEFAULT NEXTVAL('metadatavalue_seq'),
|
||||||
item_id INTEGER REFERENCES Item(item_id),
|
resource_id INTEGER NOT NULL,
|
||||||
|
resource_type_id INTEGER NOT NULL,
|
||||||
metadata_field_id INTEGER REFERENCES MetadataFieldRegistry(metadata_field_id),
|
metadata_field_id INTEGER REFERENCES MetadataFieldRegistry(metadata_field_id),
|
||||||
text_value TEXT,
|
text_value TEXT,
|
||||||
text_lang VARCHAR(24),
|
text_lang VARCHAR(24),
|
||||||
@@ -323,18 +314,16 @@ CREATE TABLE MetadataValue
|
|||||||
|
|
||||||
-- Create a dcvalue view for backwards compatibilty
|
-- Create a dcvalue view for backwards compatibilty
|
||||||
CREATE VIEW dcvalue AS
|
CREATE VIEW dcvalue AS
|
||||||
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.item_id,
|
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.resource_id,
|
||||||
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
||||||
MetadataValue.text_lang, MetadataValue.place
|
MetadataValue.text_lang, MetadataValue.place
|
||||||
FROM MetadataValue, MetadataFieldRegistry
|
FROM MetadataValue, MetadataFieldRegistry
|
||||||
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
||||||
AND MetadataFieldRegistry.metadata_schema_id = 1;
|
AND MetadataFieldRegistry.metadata_schema_id = 1 AND MetadataValue.resource_type_id = 2;
|
||||||
|
|
||||||
-- An index for item_id - almost all access is based on
|
-- An index for item_id - almost all access is based on
|
||||||
-- instantiating the item object, which grabs all values
|
-- instantiating the item object, which grabs all values
|
||||||
-- related to that item
|
-- related to that item
|
||||||
CREATE INDEX metadatavalue_item_idx ON MetadataValue(item_id);
|
|
||||||
CREATE INDEX metadatavalue_item_idx2 ON MetadataValue(item_id,metadata_field_id);
|
|
||||||
CREATE INDEX metadatavalue_field_fk_idx ON MetadataValue(metadata_field_id);
|
CREATE INDEX metadatavalue_field_fk_idx ON MetadataValue(metadata_field_id);
|
||||||
CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_id);
|
CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_id);
|
||||||
|
|
||||||
@@ -344,12 +333,7 @@ CREATE INDEX metadatafield_schema_idx ON MetadataFieldRegistry(metadata_schema_i
|
|||||||
CREATE TABLE Community
|
CREATE TABLE Community
|
||||||
(
|
(
|
||||||
community_id INTEGER PRIMARY KEY,
|
community_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR(128),
|
|
||||||
short_description VARCHAR(512),
|
|
||||||
introductory_text TEXT,
|
|
||||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||||
copyright_text TEXT,
|
|
||||||
side_bar_text TEXT,
|
|
||||||
admin INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
admin INTEGER REFERENCES EPersonGroup( eperson_group_id )
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -362,15 +346,8 @@ CREATE INDEX community_admin_fk_idx ON Community(admin);
|
|||||||
CREATE TABLE Collection
|
CREATE TABLE Collection
|
||||||
(
|
(
|
||||||
collection_id INTEGER PRIMARY KEY,
|
collection_id INTEGER PRIMARY KEY,
|
||||||
name VARCHAR(128),
|
|
||||||
short_description VARCHAR(512),
|
|
||||||
introductory_text TEXT,
|
|
||||||
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
logo_bitstream_id INTEGER REFERENCES Bitstream(bitstream_id),
|
||||||
template_item_id INTEGER REFERENCES Item(item_id),
|
template_item_id INTEGER REFERENCES Item(item_id),
|
||||||
provenance_description TEXT,
|
|
||||||
license TEXT,
|
|
||||||
copyright_text TEXT,
|
|
||||||
side_bar_text TEXT,
|
|
||||||
workflow_step_1 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_1 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
workflow_step_2 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_2 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
workflow_step_3 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
workflow_step_3 INTEGER REFERENCES EPersonGroup( eperson_group_id ),
|
||||||
@@ -645,8 +622,9 @@ CREATE TABLE community_item_count (
|
|||||||
-- and administrators
|
-- and administrators
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
-- We don't use getnextid() for 'anonymous' since the sequences start at '1'
|
-- We don't use getnextid() for 'anonymous' since the sequences start at '1'
|
||||||
INSERT INTO epersongroup VALUES(0, 'Anonymous');
|
INSERT INTO epersongroup VALUES(0);
|
||||||
INSERT INTO epersongroup VALUES(getnextid('epersongroup'), 'Administrator');
|
INSERT INTO epersongroup VALUES(getnextid('epersongroup'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
@@ -14,4 +14,317 @@ BEGIN;
|
|||||||
ALTER TABLE requestitem ADD request_message TEXT;
|
ALTER TABLE requestitem ADD request_message TEXT;
|
||||||
|
|
||||||
|
|
||||||
|
alter table metadatavalue rename item_id to resource_id;
|
||||||
|
alter table metadatavalue alter column resource_id set not null;
|
||||||
|
alter table metadatavalue add column resource_type_id integer;
|
||||||
|
UPDATE metadatavalue SET resource_type_id = 2;
|
||||||
|
alter table metadatavalue alter column resource_type_id set not null;
|
||||||
|
alter table metadatavalue drop constraint metadatavalue_item_id_fkey;
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- community
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier is null) AS metadata_field_id,
|
||||||
|
introductory_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not introductory_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'abstract') AS metadata_field_id,
|
||||||
|
short_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not short_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'tableofcontents') AS metadata_field_id,
|
||||||
|
side_bar_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not side_bar_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'rights' and qualifier is null) AS metadata_field_id,
|
||||||
|
copyright_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not copyright_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
community_id AS resource_id,
|
||||||
|
4 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM community where not name is null;
|
||||||
|
|
||||||
|
alter table community drop column introductory_text, drop column short_description, drop column side_bar_text, drop column copyright_text, drop column name;
|
||||||
|
|
||||||
|
|
||||||
|
-- ----------
|
||||||
|
-- collection
|
||||||
|
-- ----------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier is null) AS metadata_field_id,
|
||||||
|
introductory_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not introductory_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'abstract') AS metadata_field_id,
|
||||||
|
short_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not short_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier = 'tableofcontents') AS metadata_field_id,
|
||||||
|
side_bar_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not side_bar_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'rights' and qualifier is null) AS metadata_field_id,
|
||||||
|
copyright_text AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not copyright_text is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not name is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'provenance' and qualifier is null) AS metadata_field_id,
|
||||||
|
provenance_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not provenance_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
collection_id AS resource_id,
|
||||||
|
3 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'rights' and qualifier = 'license') AS metadata_field_id,
|
||||||
|
license AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM collection where not license is null;
|
||||||
|
|
||||||
|
alter table collection drop column introductory_text, drop column short_description, drop column copyright_text, drop column side_bar_text, drop column name, drop column license, drop column provenance_description;
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- bundle
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
bundle_id AS resource_id,
|
||||||
|
1 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bundle where not name is null;
|
||||||
|
|
||||||
|
alter table bundle drop column name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- bitstream
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not name is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'description' and qualifier is null) AS metadata_field_id,
|
||||||
|
description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'format' and qualifier is null) AS metadata_field_id,
|
||||||
|
user_format_description AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not user_format_description is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
bitstream_id AS resource_id,
|
||||||
|
0 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'source' and qualifier is null) AS metadata_field_id,
|
||||||
|
source AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM bitstream where not source is null;
|
||||||
|
|
||||||
|
alter table bitstream drop column name, drop column description, drop column user_format_description, drop column source;
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- epersongroup
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_group_id AS resource_id,
|
||||||
|
6 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='dc') and element = 'title' and qualifier is null) AS metadata_field_id,
|
||||||
|
name AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM epersongroup where not name is null;
|
||||||
|
|
||||||
|
alter table epersongroup drop column name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- eperson
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'email' and qualifier is null) AS metadata_field_id,
|
||||||
|
email AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not email is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'firstname' and qualifier is null) AS metadata_field_id,
|
||||||
|
firstname AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not firstname is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'lastname' and qualifier is null) AS metadata_field_id,
|
||||||
|
lastname AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not lastname is null;
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'phone' and qualifier is null) AS metadata_field_id,
|
||||||
|
phone AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not phone is null;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'netid' and qualifier is null) AS metadata_field_id,
|
||||||
|
netid AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not netid is null;
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO metadatavalue (resource_id, resource_type_id, metadata_field_id, text_value, text_lang, place)
|
||||||
|
SELECT
|
||||||
|
eperson_id AS resource_id,
|
||||||
|
7 AS resource_type_id,
|
||||||
|
(select metadata_field_id from metadatafieldregistry where metadata_schema_id=(select metadata_schema_id from metadataschemaregistry where short_id='eperson') and element = 'language' and qualifier is null) AS metadata_field_id,
|
||||||
|
language AS text_value,
|
||||||
|
null AS text_lang,
|
||||||
|
0 AS place
|
||||||
|
FROM eperson where not language is null;
|
||||||
|
|
||||||
|
|
||||||
|
alter table eperson drop column firstname, drop column lastname, drop column phone, drop column netid, drop column language;
|
||||||
|
|
||||||
|
-- ---------
|
||||||
|
-- dcvalue view
|
||||||
|
-- ---------
|
||||||
|
|
||||||
|
drop view dcvalue;
|
||||||
|
|
||||||
|
CREATE VIEW dcvalue AS
|
||||||
|
SELECT MetadataValue.metadata_value_id AS "dc_value_id", MetadataValue.resource_id,
|
||||||
|
MetadataValue.metadata_field_id AS "dc_type_id", MetadataValue.text_value,
|
||||||
|
MetadataValue.text_lang, MetadataValue.place
|
||||||
|
FROM MetadataValue, MetadataFieldRegistry
|
||||||
|
WHERE MetadataValue.metadata_field_id = MetadataFieldRegistry.metadata_field_id
|
||||||
|
AND MetadataFieldRegistry.metadata_schema_id = 1 AND MetadataValue.resource_type_id = 2;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
@@ -185,7 +185,7 @@ Common usage:
|
|||||||
<!-- Update an installation (except database) -->
|
<!-- Update an installation (except database) -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
|
|
||||||
<target name="update" depends="update_configs,update_code,update_webapps" description="Update installed code and web applications (without clobbering data/config)">
|
<target name="update" depends="update_configs,update_code,update_webapps,update_registries" description="Update installed code and web applications (without clobbering data/config)">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
@@ -879,6 +879,14 @@ Common usage:
|
|||||||
<arg line="-f '${dspace.dir}/config/registries/dcterms-types.xml'" />
|
<arg line="-f '${dspace.dir}/config/registries/dcterms-types.xml'" />
|
||||||
</java>
|
</java>
|
||||||
|
|
||||||
|
<!-- Import the new EPerson schema -->
|
||||||
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="-f '${dspace.dir}/config/registries/eperson-types.xml'" />
|
||||||
|
</java>
|
||||||
|
|
||||||
<!-- FIXME: this should be more modular -->
|
<!-- FIXME: this should be more modular -->
|
||||||
<!-- import the SWORD required metadata -->
|
<!-- import the SWORD required metadata -->
|
||||||
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
@@ -891,6 +899,52 @@ Common usage:
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
<!-- Update contents of the registries -->
|
||||||
|
<!-- ============================================================= -->
|
||||||
|
|
||||||
|
<target name="update_registries" description="Update the metadata registries">
|
||||||
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="-f '${dspace.dir}/config/registries/dublin-core-types.xml'" />
|
||||||
|
<arg line="-u"/>
|
||||||
|
</java>
|
||||||
|
|
||||||
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="-f '${dspace.dir}/config/registries/dcterms-types.xml'" />
|
||||||
|
<arg line="-u"/>
|
||||||
|
</java>
|
||||||
|
|
||||||
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="-f '${dspace.dir}/config/registries/eperson-types.xml'" />
|
||||||
|
<arg line="-u"/>
|
||||||
|
</java>
|
||||||
|
|
||||||
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="-f '${dspace.dir}/config/registries/sword-metadata.xml'" />
|
||||||
|
<arg line="-u"/>
|
||||||
|
</java>
|
||||||
|
|
||||||
|
<java classname="org.dspace.administer.MetadataImporter" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="-f '${dspace.dir}/config/registries/workflow-types.xml'" />
|
||||||
|
<arg line="-u"/>
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Install fresh code but do not touch the database -->
|
<!-- Install fresh code but do not touch the database -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
@@ -958,6 +1012,14 @@ Common usage:
|
|||||||
|
|
||||||
<antcall target="init_geolite" />
|
<antcall target="init_geolite" />
|
||||||
|
|
||||||
|
<!--Set the group names for admin & anonymous-->
|
||||||
|
<java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
<sysproperty key="dspace.configuration" value="${config}" />
|
||||||
|
<arg line="dsrun org.dspace.eperson.Group"/>
|
||||||
|
</java>
|
||||||
|
|
||||||
<java classname="org.dspace.browse.IndexBrowse" classpathref="class.path" fork="yes" failonerror="yes">
|
<java classname="org.dspace.browse.IndexBrowse" classpathref="class.path" fork="yes" failonerror="yes">
|
||||||
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
|
||||||
<sysproperty key="dspace.log.init.disable" value="true" />
|
<sysproperty key="dspace.log.init.disable" value="true" />
|
||||||
|
Reference in New Issue
Block a user