public L1CacheRepositoryDecorator(Repository<Entity> delegateRepository, L1Cache l1Cache) { super(delegateRepository); this.l1Cache = requireNonNull(l1Cache); this.cacheable = delegateRepository.getCapabilities().containsAll(newArrayList(CACHEABLE, WRITABLE)); }
public L2CacheRepositoryDecorator( Repository<Entity> delegateRepository, L2Cache l2Cache, TransactionInformation transactionInformation) { super(delegateRepository); this.l2Cache = requireNonNull(l2Cache); this.cacheable = delegateRepository.getCapabilities().containsAll(newArrayList(CACHEABLE)); this.transactionInformation = transactionInformation; }
public L3CacheRepositoryDecorator( Repository<Entity> delegateRepository, L3Cache l3Cache, TransactionInformation transactionInformation) { super(delegateRepository); this.l3Cache = requireNonNull(l3Cache); this.cacheable = delegateRepository.getCapabilities().containsAll(newArrayList(CACHEABLE)); this.transactionInformation = requireNonNull(transactionInformation); }
@Override public Set<RepositoryCapability> getCapabilities() { Set<RepositoryCapability> capabilities = new HashSet<>(); capabilities.add(RepositoryCapability.INDEXABLE); capabilities.addAll(delegate().getCapabilities()); return capabilities; }
/** * Gets the capabilities of the underlying repository and adds three read capabilities provided by * the index: {@link RepositoryCapability#INDEXABLE}, {@link RepositoryCapability#QUERYABLE} and * {@link RepositoryCapability#AGGREGATEABLE}. Does not add other index capabilities like{@link * RepositoryCapability#WRITABLE} because those might conflict with the underlying repository. */ @Override public Set<RepositoryCapability> getCapabilities() { Set<RepositoryCapability> capabilities = new HashSet<>(); capabilities.addAll(delegate().getCapabilities()); capabilities.addAll(EnumSet.of(QUERYABLE, AGGREGATEABLE)); return unmodifiableSet(capabilities); }
@Override @PreAuthorize("hasAnyRole('ROLE_SU')") public void rebuildIndex(String entityTypeId) { Repository<Entity> repository = dataService.getRepository(entityTypeId); if (!repository.getCapabilities().contains(RepositoryCapability.INDEXABLE)) { throw new MolgenisDataAccessException( "Repository [" + entityTypeId + "] is not an indexed repository"); } indexService.rebuildIndex(repository); } }
@Override @PreAuthorize("hasAnyRole('ROLE_SU, ROLE_PLUGIN_READ_indexmanager')") public List<EntityType> getIndexedEntities() { // collect indexed repos List<EntityType> indexedEntityTypeList = new ArrayList<>(); dataService .getEntityTypeIds() .forEach( entityTypeId -> { Repository<Entity> repository = dataService.getRepository(entityTypeId); if (repository != null && repository.getCapabilities().contains(RepositoryCapability.INDEXABLE)) { indexedEntityTypeList.add(repository.getEntityType()); } }); // sort indexed repos by entity label indexedEntityTypeList.sort(Comparator.comparing(EntityType::getLabel)); return indexedEntityTypeList; }
private void annotate(RepositoryAnnotator annotator, Repository<Entity> repository, DatabaseAction action) if (!repository.getCapabilities().contains(WRITABLE))