public Context withMetadataFormat(String prefix, Transformer transformer, Condition condition) { withMetadataFormat( new MetadataFormat() .withNamespace(prefix) .withPrefix(prefix) .withSchemaLocation(prefix) .withTransformer(transformer) .withCondition(condition) ); return this; }
private Context addDataverseJsonMetadataFormat(Context context) { MetadataFormat metadataFormat = MetadataFormat.metadataFormat(DATAVERSE_EXTENDED_METADATA_FORMAT); metadataFormat.withNamespace(DATAVERSE_EXTENDED_METADATA_INFO); metadataFormat.withSchemaLocation(DATAVERSE_EXTENDED_METADATA_SCHEMA); context.withMetadataFormat(metadataFormat); return context; }
public InMemoryItem withIdentifier(String identifier) { this.with("identifier", identifier); return this; } }
private List<ScopedFilter> getScopedFilters(Context context, String metadataPrefix) throws CannotDisseminateFormatException { List<ScopedFilter> filters = new ArrayList<ScopedFilter>(); if (context.hasCondition()) filters.add(new ScopedFilter(context.getCondition(), Scope.Context)); MetadataFormat metadataFormat = context.formatForPrefix(metadataPrefix); if (metadataFormat.hasCondition()) filters.add(new ScopedFilter(metadataFormat.getCondition(), Scope.MetadataFormat)); return filters; }
public List<Set> getSets(Context context, FilterResolver resolver) { List<Set> result = new ArrayList<Set>(); for (Set set : context.getSets()) if (set.getCondition().getFilter(resolver).isItemShown(item)) result.add(set); result.addAll(item.getSets()); return result; } }
public boolean isStaticSet(String setSpec) { for (Set set : this.sets) if (set.getSpec().equals(setSpec)) return true; return false; }
@Override public com.lyncode.xoai.dataprovider.model.Set apply(String elem) { return new com.lyncode.xoai.dataprovider.model.Set(elem); } });
public static Context context () { return new Context(); }
public static MetadataFormat metadataFormat (String prefix) { return new MetadataFormat().withPrefix(prefix); }
public boolean hasSet(String set) { return isStaticSet(set); }
public static InMemoryItem item () { return new InMemoryItem(); }
public MetadataFormat formatForPrefix(String metadataPrefix) { for (MetadataFormat format : this.metadataFormats) if (format.getPrefix().equals(metadataPrefix)) return format; return null; }
public InMemoryItemRepository withRandomItems(int number) { for (int i = 0; i < number; i++) list.add(InMemoryItem.randomItem()); return this; }
public Context withMetadataFormat(String prefix, Transformer transformer) { withMetadataFormat(new MetadataFormat().withNamespace(prefix).withPrefix(prefix).withSchemaLocation(prefix).withTransformer(transformer)); return this; }
@Override public boolean exists(String setSpec) { for (Set s : this.sets) if (s.getSpec().equals(setSpec)) return true; return false; } }
public static Set set (String spec) { return new Set(spec); }
private Context createContext() { Context context = new Context(); addSupportedMetadataFormats(context); return context; }
public Set getSet(String setSpec) { for (Set set : this.sets) if (set.getSpec().equals(setSpec)) return set; return null; }