mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
[DS-2701] oai remove even more database support.
This commit is contained in:
@@ -1,74 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.xoai.data;
|
|
||||||
|
|
||||||
import com.lyncode.xoai.dataprovider.core.ItemMetadata;
|
|
||||||
import com.lyncode.xoai.dataprovider.core.ReferenceSet;
|
|
||||||
import com.lyncode.xoai.dataprovider.xml.xoai.Metadata;
|
|
||||||
import org.apache.log4j.LogManager;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.content.Item;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Lyncode Development Team <dspace@lyncode.com>
|
|
||||||
*/
|
|
||||||
public class DSpaceDatabaseItem extends DSpaceItem
|
|
||||||
{
|
|
||||||
private static Logger log = LogManager.getLogger(DSpaceDatabaseItem.class);
|
|
||||||
|
|
||||||
private Item item;
|
|
||||||
private List<ReferenceSet> sets;
|
|
||||||
|
|
||||||
public DSpaceDatabaseItem(Item item, Metadata metadata, List<ReferenceSet> sets)
|
|
||||||
{
|
|
||||||
this.item = item;
|
|
||||||
this.metadata = new ItemMetadata(metadata);
|
|
||||||
this.sets = sets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getDatestamp()
|
|
||||||
{
|
|
||||||
return item.getLastModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ReferenceSet> getSets()
|
|
||||||
{
|
|
||||||
return sets;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDeleted()
|
|
||||||
{
|
|
||||||
return item.isWithdrawn();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemMetadata metadata = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemMetadata getMetadata()
|
|
||||||
{
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Item getItem()
|
|
||||||
{
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getHandle()
|
|
||||||
{
|
|
||||||
return item.getHandle();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -15,10 +15,8 @@ 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.xoai.data.DSpaceItem;
|
import org.dspace.xoai.data.DSpaceItem;
|
||||||
import org.dspace.xoai.filter.data.DSpaceMetadataFilterOperator;
|
import org.dspace.xoai.filter.data.DSpaceMetadataFilterOperator;
|
||||||
import org.dspace.xoai.filter.results.DatabaseFilterResult;
|
|
||||||
import org.dspace.xoai.filter.results.SolrFilterResult;
|
import org.dspace.xoai.filter.results.SolrFilterResult;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
@@ -50,7 +48,7 @@ public class DSpaceAtLeastOneMetadataFilter extends DSpaceFilter {
|
|||||||
if (parameterValue == null) parameterValue = getConfiguration().get("values");
|
if (parameterValue == null) parameterValue = getConfiguration().get("values");
|
||||||
|
|
||||||
if (parameterValue instanceof SimpleType) {
|
if (parameterValue instanceof SimpleType) {
|
||||||
values = new ArrayList<String>();
|
values = new ArrayList<>();
|
||||||
values.add(((SimpleType) parameterValue).asString());
|
values.add(((SimpleType) parameterValue).asString());
|
||||||
} else if (parameterValue instanceof ParameterList) {
|
} else if (parameterValue instanceof ParameterList) {
|
||||||
values = new ListBuilder<ParameterValue>()
|
values = new ListBuilder<ParameterValue>()
|
||||||
@@ -61,7 +59,7 @@ public class DSpaceAtLeastOneMetadataFilter extends DSpaceFilter {
|
|||||||
return elem.asSimpleType().asString();
|
return elem.asSimpleType().asString();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else values = new ArrayList<String>();
|
} else values = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
@@ -120,65 +118,10 @@ public class DSpaceAtLeastOneMetadataFilter extends DSpaceFilter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseFilterResult getWhere(int mdid, List<String> values) {
|
|
||||||
List<String> parts = new ArrayList<String>();
|
|
||||||
List<Object> params = new ArrayList<Object>();
|
|
||||||
params.add(mdid);
|
|
||||||
for (String v : values)
|
|
||||||
this.buildWhere(v, parts, params);
|
|
||||||
if (parts.size() > 0) {
|
|
||||||
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 ("
|
|
||||||
+ StringUtils.join(parts.iterator(), " OR ")
|
|
||||||
+ "))";
|
|
||||||
return new DatabaseFilterResult(query, params);
|
|
||||||
}
|
|
||||||
return new DatabaseFilterResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildWhere(String value, List<String> parts,
|
|
||||||
List<Object> params) {
|
|
||||||
switch (this.getOperator()) {
|
|
||||||
case ENDS_WITH:
|
|
||||||
parts.add("(tmp.text_value LIKE ?)");
|
|
||||||
params.add("%" + value);
|
|
||||||
break;
|
|
||||||
case STARTS_WITH:
|
|
||||||
parts.add("(tmp.text_value LIKE ?)");
|
|
||||||
params.add(value + "%");
|
|
||||||
break;
|
|
||||||
case EQUAL:
|
|
||||||
parts.add("(tmp.text_value LIKE ?)");
|
|
||||||
params.add(value);
|
|
||||||
break;
|
|
||||||
case GREATER:
|
|
||||||
parts.add("(tmp.text_value > ?)");
|
|
||||||
params.add(value);
|
|
||||||
break;
|
|
||||||
case LOWER:
|
|
||||||
parts.add("(tmp.text_value < ?)");
|
|
||||||
params.add(value);
|
|
||||||
break;
|
|
||||||
case LOWER_OR_EQUAL:
|
|
||||||
parts.add("(tmp.text_value <= ?)");
|
|
||||||
params.add(value);
|
|
||||||
break;
|
|
||||||
case GREATER_OR_EQUAL:
|
|
||||||
parts.add("(tmp.text_value >= ?)");
|
|
||||||
params.add(value);
|
|
||||||
break;
|
|
||||||
case CONTAINS:
|
|
||||||
default:
|
|
||||||
parts.add("(tmp.text_value LIKE ?)");
|
|
||||||
params.add("%" + value + "%");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SolrFilterResult buildSolrQuery() {
|
public SolrFilterResult buildSolrQuery() {
|
||||||
String field = this.getField();
|
String field = this.getField();
|
||||||
List<String> parts = new ArrayList<String>();
|
List<String> parts = new ArrayList<>();
|
||||||
if (this.getField() != null) {
|
if (this.getField() != null) {
|
||||||
for (String v : this.getValues())
|
for (String v : this.getValues())
|
||||||
this.buildQuery("metadata." + field,
|
this.buildQuery("metadata." + field,
|
||||||
|
@@ -13,7 +13,6 @@ import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterMap;
|
|||||||
|
|
||||||
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.filter.results.DatabaseFilterResult;
|
|
||||||
import org.dspace.xoai.filter.results.SolrFilterResult;
|
import org.dspace.xoai.filter.results.SolrFilterResult;
|
||||||
import org.dspace.xoai.services.api.FieldResolver;
|
import org.dspace.xoai.services.api.FieldResolver;
|
||||||
|
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.xoai.filter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Lyncode Development Team <dspace@lyncode.com>
|
|
||||||
*/
|
|
||||||
public class DatabaseFilterResult
|
|
||||||
{
|
|
||||||
private String _where;
|
|
||||||
|
|
||||||
private List<Object> _params;
|
|
||||||
|
|
||||||
private boolean _nothing;
|
|
||||||
|
|
||||||
public DatabaseFilterResult()
|
|
||||||
{
|
|
||||||
_nothing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseFilterResult(String where, Object... params)
|
|
||||||
{
|
|
||||||
_nothing = false;
|
|
||||||
_where = where;
|
|
||||||
_params = new ArrayList<Object>();
|
|
||||||
for (Object obj : params)
|
|
||||||
_params.add(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseFilterResult(String where, List<Object> params)
|
|
||||||
{
|
|
||||||
_nothing = false;
|
|
||||||
_where = where;
|
|
||||||
_params = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasResult()
|
|
||||||
{
|
|
||||||
return !_nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWhere()
|
|
||||||
{
|
|
||||||
return _where;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Object> getParameters()
|
|
||||||
{
|
|
||||||
return _params;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -11,9 +11,7 @@ import com.lyncode.builder.DateBuilder;
|
|||||||
import com.lyncode.xoai.dataprovider.services.api.DateProvider;
|
import com.lyncode.xoai.dataprovider.services.api.DateProvider;
|
||||||
import com.lyncode.xoai.dataprovider.services.impl.BaseDateProvider;
|
import com.lyncode.xoai.dataprovider.services.impl.BaseDateProvider;
|
||||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||||
import org.dspace.core.Context;
|
|
||||||
import org.dspace.xoai.data.DSpaceItem;
|
import org.dspace.xoai.data.DSpaceItem;
|
||||||
import org.dspace.xoai.filter.results.DatabaseFilterResult;
|
|
||||||
import org.dspace.xoai.filter.results.SolrFilterResult;
|
import org.dspace.xoai.filter.results.SolrFilterResult;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.xoai.filter.results;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Lyncode Development Team <dspace@lyncode.com>
|
|
||||||
*/
|
|
||||||
public class DatabaseFilterResult
|
|
||||||
{
|
|
||||||
private String where;
|
|
||||||
private List<Object> parameters;
|
|
||||||
private boolean nothing;
|
|
||||||
|
|
||||||
public DatabaseFilterResult()
|
|
||||||
{
|
|
||||||
nothing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseFilterResult(String where, Object... params)
|
|
||||||
{
|
|
||||||
nothing = false;
|
|
||||||
this.where = where;
|
|
||||||
parameters = new ArrayList<Object>();
|
|
||||||
for (Object obj : params)
|
|
||||||
parameters.add(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseFilterResult(String where, List<Object> params)
|
|
||||||
{
|
|
||||||
nothing = false;
|
|
||||||
this.where = where;
|
|
||||||
parameters = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasResult()
|
|
||||||
{
|
|
||||||
return !nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQuery()
|
|
||||||
{
|
|
||||||
return where;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Object> getParameters()
|
|
||||||
{
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -13,7 +13,6 @@ import com.lyncode.xoai.dataprovider.filter.conditions.*;
|
|||||||
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterMap;
|
import com.lyncode.xoai.dataprovider.xml.xoaiconfig.parameters.ParameterMap;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.xoai.filter.*;
|
import org.dspace.xoai.filter.*;
|
||||||
import org.dspace.xoai.filter.results.DatabaseFilterResult;
|
|
||||||
import org.dspace.xoai.filter.results.SolrFilterResult;
|
import org.dspace.xoai.filter.results.SolrFilterResult;
|
||||||
import org.dspace.xoai.services.api.context.ContextService;
|
import org.dspace.xoai.services.api.context.ContextService;
|
||||||
import org.dspace.xoai.services.api.context.ContextServiceException;
|
import org.dspace.xoai.services.api.context.ContextServiceException;
|
||||||
@@ -21,8 +20,6 @@ import org.dspace.xoai.services.api.FieldResolver;
|
|||||||
import org.dspace.xoai.services.api.xoai.DSpaceFilterResolver;
|
import org.dspace.xoai.services.api.xoai.DSpaceFilterResolver;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.lyncode.xoai.dataprovider.filter.Scope.MetadataFormat;
|
import static com.lyncode.xoai.dataprovider.filter.Scope.MetadataFormat;
|
||||||
|
|
||||||
public class BaseDSpaceFilterResolver implements DSpaceFilterResolver {
|
public class BaseDSpaceFilterResolver implements DSpaceFilterResolver {
|
||||||
|
@@ -74,9 +74,7 @@ public class ItemUtils
|
|||||||
}
|
}
|
||||||
public static Metadata retrieveMetadata (Context context, Item item) {
|
public static Metadata retrieveMetadata (Context context, Item item) {
|
||||||
Metadata metadata;
|
Metadata metadata;
|
||||||
|
|
||||||
//DSpaceDatabaseItem dspaceItem = new DSpaceDatabaseItem(item);
|
|
||||||
|
|
||||||
// read all metadata into Metadata Object
|
// read all metadata into Metadata Object
|
||||||
metadata = new Metadata();
|
metadata = new Metadata();
|
||||||
List<MetadataValue> vals = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
List<MetadataValue> vals = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||||
|
Reference in New Issue
Block a user