mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
[DS-4522] Refactor LogicalStatement.getResult() type to primitive boolean
This commit is contained in:
@@ -40,7 +40,7 @@ public class DefaultFilter implements Filter {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
return this.statement.getResult(context, item);
|
return this.statement.getResult(context, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,5 +31,5 @@ public interface Filter extends LogicalStatement {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
Boolean getResult(Context context, Item item) throws LogicalStatementException;
|
boolean getResult(Context context, Item item) throws LogicalStatementException;
|
||||||
}
|
}
|
||||||
|
@@ -27,5 +27,5 @@ public interface LogicalStatement {
|
|||||||
* @return boolean result of evaluation
|
* @return boolean result of evaluation
|
||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
Boolean getResult(Context context, Item item) throws LogicalStatementException;
|
boolean getResult(Context context, Item item) throws LogicalStatementException;
|
||||||
}
|
}
|
||||||
|
@@ -110,7 +110,7 @@ public class TestLogicRunner {
|
|||||||
DSpaceObject dso = handleService.resolveToObject(c, handle);
|
DSpaceObject dso = handleService.resolveToObject(c, handle);
|
||||||
if (Constants.typeText[dso.getType()].equals("ITEM")) {
|
if (Constants.typeText[dso.getType()].equals("ITEM")) {
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
System.out.println(filter.getResult(c, item).toString());
|
System.out.println(filter.getResult(c, item));
|
||||||
} else {
|
} else {
|
||||||
System.out.println(handle + " is not an ITEM");
|
System.out.println(handle + " is not an ITEM");
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ public class TestLogicRunner {
|
|||||||
System.out.println(
|
System.out.println(
|
||||||
"Testing '" + filter + "' on item " + i.getHandle() + " ('" + i.getName() + "')"
|
"Testing '" + filter + "' on item " + i.getHandle() + " ('" + i.getName() + "')"
|
||||||
);
|
);
|
||||||
System.out.println(filter.getResult(c, i).toString());
|
System.out.println(filter.getResult(c, i));
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (SQLException | LogicalStatementException e) {
|
} catch (SQLException | LogicalStatementException e) {
|
||||||
|
@@ -73,7 +73,7 @@ public abstract class AbstractCondition implements Condition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
log.error("Error evaluating item. Passed item is null, returning false");
|
log.error("Error evaluating item. Passed item is null, returning false");
|
||||||
return false;
|
return false;
|
||||||
|
@@ -30,7 +30,7 @@ public class BitstreamCountCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
|
|
||||||
// This super call just throws some useful exceptions if required objects are null
|
// This super call just throws some useful exceptions if required objects are null
|
||||||
super.getResult(context, item);
|
super.getResult(context, item);
|
||||||
|
@@ -48,7 +48,7 @@ public interface Condition extends LogicalStatement {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
Boolean getResult(Context context, Item item) throws LogicalStatementException;
|
boolean getResult(Context context, Item item) throws LogicalStatementException;
|
||||||
|
|
||||||
public void setItemService(ItemService itemService);
|
public void setItemService(ItemService itemService);
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ public class InCollectionCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
|
|
||||||
List<String> collectionHandles = (List<String>)getParameters().get("collections");
|
List<String> collectionHandles = (List<String>)getParameters().get("collections");
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ public class InCommunityCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
|
|
||||||
List<String> communityHandles = (List<String>)getParameters().get("communities");
|
List<String> communityHandles = (List<String>)getParameters().get("communities");
|
||||||
List<Collection> itemCollections = item.getCollections();
|
List<Collection> itemCollections = item.getCollections();
|
||||||
|
@@ -30,7 +30,7 @@ public class IsWithdrawnCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
log.debug("Result of isWithdrawn is " + item.isWithdrawn());
|
log.debug("Result of isWithdrawn is " + item.isWithdrawn());
|
||||||
return item.isWithdrawn();
|
return item.isWithdrawn();
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ public class MetadataValueMatchCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
String field = (String)getParameters().get("field");
|
String field = (String)getParameters().get("field");
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -37,7 +37,7 @@ public class MetadataValuesMatchCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
String field = (String)getParameters().get("field");
|
String field = (String)getParameters().get("field");
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -40,7 +40,7 @@ public class ReadableByGroupCondition extends AbstractCondition {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
|
|
||||||
String group = (String)getParameters().get("group");
|
String group = (String)getParameters().get("group");
|
||||||
String action = (String)getParameters().get("action");
|
String action = (String)getParameters().get("action");
|
||||||
|
@@ -65,7 +65,7 @@ public abstract class AbstractOperator implements LogicalStatement {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ public class And extends AbstractOperator {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
|
|
||||||
for (LogicalStatement statement : getStatements()) {
|
for (LogicalStatement statement : getStatements()) {
|
||||||
if (!statement.getResult(context, item)) {
|
if (!statement.getResult(context, item)) {
|
||||||
|
@@ -46,7 +46,7 @@ public class Nand extends AbstractOperator {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
return !(new And(getStatements()).getResult(context, item));
|
return !(new And(getStatements()).getResult(context, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ public class Nor extends AbstractOperator {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
return !(new Or(getStatements()).getResult(context, item));
|
return !(new Or(getStatements()).getResult(context, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -63,7 +63,7 @@ public class Not implements LogicalStatement {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
return !statement.getResult(context, item);
|
return !statement.getResult(context, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ public class Or extends AbstractOperator {
|
|||||||
* @throws LogicalStatementException
|
* @throws LogicalStatementException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean getResult(Context context, Item item) throws LogicalStatementException {
|
public boolean getResult(Context context, Item item) throws LogicalStatementException {
|
||||||
|
|
||||||
for (LogicalStatement statement : getStatements()) {
|
for (LogicalStatement statement : getStatements()) {
|
||||||
if (statement.getResult(context, item)) {
|
if (statement.getResult(context, item)) {
|
||||||
|
Reference in New Issue
Block a user