Tabnine Logo
Context
Code IndexAdd Tabnine to your IDE (free)

How to use
Context
in
com.lyncode.xoai.dataprovider.model

Best Java code snippets using com.lyncode.xoai.dataprovider.model.Context (Showing top 20 results out of 315)

origin: com.lyncode/xoai-data-provider

public static Context context () {
  return new Context();
}
origin: com.lyncode/xoai-data-provider

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;
}
origin: com.lyncode/xoai-data-provider

public ListMetadataFormatsHandler(Context context, Repository repository) {
  super(context, repository);
  itemRepositoryHelper = new ItemRepositoryHelper(repository.getItemRepository());
  // Static validation
  if (getContext().getMetadataFormats() == null ||
      getContext().getMetadataFormats().isEmpty())
    throw new InternalOAIException("The context must expose at least one metadata format");
}
origin: com.lyncode/xoai-data-provider

public ListItemsResults getItemsUntil(Context context, int offset,
                   int length, String metadataPrefix, String setSpec, Date until)
    throws CannotDisseminateFormatException, OAIException {
  List<ScopedFilter> filters = getScopedFilters(context, metadataPrefix);
  if (context.isStaticSet(setSpec)) {
    filters.add(new ScopedFilter(context.getSet(setSpec).getCondition(), Scope.Set));
    return itemRepository.getItemsUntil(filters, offset, length, until);
  } else
    return itemRepository.getItemsUntil(filters, offset, length, setSpec, until);
}
origin: com.lyncode/xoai-data-provider

GetRecord result = new GetRecord(record);
MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
Item item = getRepository().getItemRepository().getItem(parameters.getIdentifier());
if (getContext().hasCondition() &&
    !getContext().getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
  throw new IdDoesNotExistException("This context does not include this item");
header.withDatestamp(item.getDatestamp());
for (Set set : getContext().getSets())
  if (set.getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
    header.withSetSpec(set.getSpec());
  Metadata metadata = null;
  try {
    if (getContext().hasTransformer()) {
      metadata = new Metadata(toPipeline(item)
          .apply(getContext().getTransformer())
          .apply(format.getTransformer())
          .process());
origin: com.lyncode/xoai-data-provider

private Record createRecord(OAICompiledRequest parameters, Item item)
    throws BadArgumentException, CannotDisseminateRecordException,
    OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
  MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
  Header header = new Header();
  Record record = new Record().withHeader(header);
    Metadata metadata = null;
    try {
      if (getContext().hasTransformer()) {
        metadata = new Metadata(toPipeline(item)
            .apply(getContext().getTransformer())
            .apply(format.getTransformer())
            .process());
origin: IQSS/dataverse

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;
}

origin: com.lyncode/xoai-data-provider

private Header createHeader(OAICompiledRequest parameters,
                ItemIdentifier itemIdentifier) throws BadArgumentException,
    OAIException,
    NoMetadataFormatsException {
  MetadataFormat format = getContext().formatForPrefix(parameters
      .getMetadataPrefix());
  if (!itemIdentifier.isDeleted() && !canDisseminate(itemIdentifier, format))
    throw new InternalOAIException("The item repository is currently providing items which cannot be disseminated with format "+format.getPrefix());
  Header header = new Header();
  header.withDatestamp(itemIdentifier.getDatestamp());
  header.withIdentifier(itemIdentifier.getIdentifier());
  if (itemIdentifier.isDeleted())
    header.withStatus(Header.Status.DELETED);
  for (Set set : getContext().getSets())
    if (set.getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(itemIdentifier))
      header.withSetSpec(set.getSpec());
  for (Set set : itemIdentifier.getSets())
    header.withSetSpec(set.getSpec());
  return header;
}
origin: IQSS/dataverse

private Record createRecord(OAICompiledRequest parameters, Item item)
    throws BadArgumentException, CannotDisseminateRecordException,
    OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
  MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
  Header header = new Header();
  
  Dataset dataset = ((Xitem)item).getDataset();
  Xrecord xrecord = new Xrecord().withFormatName(parameters.getMetadataPrefix()).withDataset(dataset);
  header.withIdentifier(item.getIdentifier());
  ItemHelper itemHelperWrap = new ItemHelper(item);
  header.withDatestamp(item.getDatestamp());
  for (Set set : itemHelperWrap.getSets(getContext(), getRepository().getFilterResolver()))
    header.withSetSpec(set.getSpec());
  if (item.isDeleted())
    header.withStatus(Header.Status.DELETED);
  xrecord.withHeader(header);
  xrecord.withMetadata(item.getMetadata());
  
  return xrecord;
}
origin: com.lyncode/xoai-data-provider

@Override
public ListMetadataFormats handle(OAICompiledRequest params) throws OAIException, HandlerException {
  ListMetadataFormats result = new ListMetadataFormats();
  if (params.hasIdentifier()) {
    Item item = itemRepositoryHelper.getItem(params.getIdentifier());
    List<MetadataFormat> metadataFormats = getContext().formatFor(getRepository().getFilterResolver(), item);
    if (metadataFormats.isEmpty())
      throw new NoMetadataFormatsException();
    for (MetadataFormat metadataFormat : metadataFormats) {
      com.lyncode.xoai.model.oaipmh.MetadataFormat format = new com.lyncode.xoai.model.oaipmh.MetadataFormat()
        .withMetadataPrefix(metadataFormat.getPrefix())
        .withMetadataNamespace(metadataFormat.getNamespace())
        .withSchema(metadataFormat.getSchemaLocation());
      result.withMetadataFormat(format);
    }
  } else {
    for (MetadataFormat metadataFormat : getContext().getMetadataFormats()) {
      com.lyncode.xoai.model.oaipmh.MetadataFormat format = new com.lyncode.xoai.model.oaipmh.MetadataFormat()
          .withMetadataPrefix(metadataFormat.getPrefix())
          .withMetadataNamespace(metadataFormat.getNamespace())
          .withSchema(metadataFormat.getSchemaLocation());
      result.withMetadataFormat(format);
    }
  }
  return result;
}
origin: com.lyncode/xoai-data-provider

public boolean exists(Context context, String setSpec) {
  List<Set> statics = context.getSets();
  for (Set set : statics)
    if (set.getSpec().equals(set))
      return true;
  return setRepository.exists(setSpec);
}
origin: com.lyncode/xoai-data-provider

public ListItemsResults getItems(Context context, int offset,
                 int length, String metadataPrefix, String setSpec, Date from,
                 Date until) throws CannotDisseminateFormatException, OAIException {
  List<ScopedFilter> filters = getScopedFilters(context, metadataPrefix);
  if (context.isStaticSet(setSpec)) {
    filters.add(new ScopedFilter(context.getSet(setSpec).getCondition(), Scope.Set));
    return itemRepository.getItems(filters, offset, length, from, until);
  } else
    return itemRepository.getItems(filters, offset, length, setSpec, from, until);
}
origin: com.lyncode/xoai-data-provider

public Context withMetadataFormat(String prefix, Transformer transformer) {
  withMetadataFormat(new MetadataFormat().withNamespace(prefix).withPrefix(prefix).withSchemaLocation(prefix).withTransformer(transformer));
  return this;
}
origin: IQSS/dataverse

private Xrecord createRecord(OAICompiledRequest parameters, Item item)
    throws BadArgumentException, CannotDisseminateRecordException,
    OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
  MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
  Header header = new Header();
  
  Dataset dataset = ((Xitem)item).getDataset();
  Xrecord xrecord = new Xrecord().withFormatName(parameters.getMetadataPrefix()).withDataset(dataset);
  header.withIdentifier(item.getIdentifier());
  ItemHelper itemHelperWrap = new ItemHelper(item);
  header.withDatestamp(item.getDatestamp());
  for (Set set : itemHelperWrap.getSets(getContext(), getRepository().getFilterResolver()))
    header.withSetSpec(set.getSpec());
  if (item.isDeleted())
    header.withStatus(Header.Status.DELETED);
  xrecord.withHeader(header);
  xrecord.withMetadata(item.getMetadata());
  
  return xrecord;
}
origin: com.lyncode/xoai-data-provider

  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;
  }
}
origin: IQSS/dataverse

@Override
public GetRecord handle(OAICompiledRequest parameters) throws OAIException, HandlerException {        
  MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
  Item item = getRepository().getItemRepository().getItem(parameters.getIdentifier());
  if (getContext().hasCondition() &&
      !getContext().getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
    throw new IdDoesNotExistException("This context does not include this item");
  if (format.hasCondition() &&
      !format.getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
    throw new CannotDisseminateRecordException("Format not applicable to this item");
  
  Xrecord record = this.createRecord(parameters, item);
  GetRecord result = new XgetRecord(record);
  
  return result;
}

origin: com.lyncode/xoai-data-provider

public ListItemIdentifiersResult getItemIdentifiers(Context context,
                          int offset, int length, String metadataPrefix, String setSpec)
    throws CannotDisseminateFormatException, OAIException {
  List<ScopedFilter> filters = getScopedFilters(context, metadataPrefix);
  if (context.isStaticSet(setSpec)) {
    filters.add(new ScopedFilter(context.getSet(setSpec).getCondition(), Scope.Set));
    return itemRepository.getItemIdentifiers(filters, offset, length);
  } else
    return itemRepository.getItemIdentifiers(filters, offset, length, setSpec);
}
origin: com.lyncode/xoai-data-provider

public Context withMetadataFormat(String prefix, Transformer transformer, Condition condition) {
  withMetadataFormat(
      new MetadataFormat()
          .withNamespace(prefix)
          .withPrefix(prefix)
          .withSchemaLocation(prefix)
          .withTransformer(transformer)
          .withCondition(condition)
  );
  return this;
}
origin: IQSS/dataverse

private Context createContext() {
  
  Context context = new Context();
  addSupportedMetadataFormats(context);
  return context;
}

origin: com.lyncode/xoai-data-provider

public ListSetsResult getSets(Context context, int offset, int length) {
  List<Set> results = new ArrayList<Set>();
  List<Set> statics = context.getSets();
  if (offset < statics.size()) {
    log.debug("Offset less than static sets size");
com.lyncode.xoai.dataprovider.modelContext

Most used methods

  • <init>
  • formatForPrefix
  • getCondition
  • hasCondition
  • withMetadataFormat
  • formatFor
  • getMetadataFormats
  • getSet
  • getSets
  • getTransformer
  • hasSet
  • hasTransformer
  • hasSet,
  • hasTransformer,
  • isStaticSet

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now