@Override public List<com.lyncode.xoai.dataprovider.model.Set> getSets() { List<String> list = ((List<String>) values.get("sets")); return new ListBuilder<String>().add(list.toArray(new String[list.size()])).build(new Function<String, com.lyncode.xoai.dataprovider.model.Set>() { @Override public com.lyncode.xoai.dataprovider.model.Set apply(String elem) { return new com.lyncode.xoai.dataprovider.model.Set(elem); } }); }
public static String[] keywords () { List<String> list = new ListBuilder<JtwigKeyword>().add(JtwigKeyword.values()).build(extractWord()); return list.toArray(new String[list.size()]); }
public static String[] keywords () { List<String> list = new ListBuilder<JtwigKeyword>().add(JtwigKeyword.values()).build(extractWord()); return list.toArray(new String[list.size()]); }
@Override public ListItemIdentifiersResult getItemIdentifiers( List<ScopedFilter> filters, int offset, int length) { try { QueryResult queryResult = retrieveItems(filters, offset, length); List<ItemIdentifier> identifierList = new ListBuilder<Item>() .add(queryResult.getResults()) .build(new Function<Item, ItemIdentifier>() { @Override public ItemIdentifier apply(Item elem) { return elem; } }); return new ListItemIdentifiersResult(queryResult.hasMore(), identifierList, queryResult.getTotal()); } catch (DSpaceSolrException ex) { log.error(ex.getMessage(), ex); return new ListItemIdentifiersResult(false, new ArrayList<ItemIdentifier>()); } }
public InMemoryItem withDefaults() { this .with("identifier", randomAlphabetic(10)) .with("datestamp", new Date()) .with("sets", new ListBuilder<String>().add(randomAlphabetic(3)).build()) .with("deleted", Integer.parseInt(randomNumeric(1)) > 5); return this; }
public static InMemoryItem randomItem() { return new InMemoryItem() .with("identifier", randomAlphabetic(10)) .with("datestamp", new Date()) .with("sets", new ListBuilder<String>().add(randomAlphabetic(3)).build()) .with("deleted", Integer.parseInt(randomNumeric(1)) > 5); }
private List<String> getValues() { if (values == null) { ParameterValue parameterValue = getConfiguration().get("value"); if (parameterValue == null) { parameterValue = getConfiguration().get("values"); } if (parameterValue instanceof SimpleType) { values = new ArrayList<>(); values.add(((SimpleType) parameterValue).asString()); } else if (parameterValue instanceof ParameterList) { values = new ListBuilder<ParameterValue>() .add(parameterValue.asParameterList().getValues()) .build(new Function<ParameterValue, String>() { @Override public String apply(ParameterValue elem) { return elem.asSimpleType().asString(); } }); } else { values = new ArrayList<>(); } } return values; }
@Override public Object calculate(JtwigContext context) throws CalculateException { try { Object resolved = expression.calculate(context); for (FunctionElement functionElement : filters) { List<Object> arguments = new ListBuilder<Object>() .add(resolved) .add(functionElement.getArguments().calculate(context).toArray()) .build(); resolved = context.function(functionElement.getName()).execute(arguments.toArray()); } return resolved; } catch (FunctionException e) { throw new CalculateException(e); } catch (FunctionNotFoundException e) { throw new CalculateException(e); } } }
@Override public Object calculate(JtwigContext context) throws CalculateException { try { Object resolved = expression.calculate(context); for (FunctionElement functionElement : filters) { List<Object> arguments = new ListBuilder<Object>() .add(resolved) .add(functionElement.getArguments().calculate(context).toArray()) .build(); resolved = context.function(functionElement.getName()).execute(arguments.toArray()); } return resolved; } catch (FunctionException e) { throw new CalculateException(e); } catch (FunctionNotFoundException e) { throw new CalculateException(e); } } }