internal static void AddRelation(this IEnumerable <ICoreRelationsRepository> session, IReadonlyRelation <IRelatableEntity, IRelatableEntity> relation, Uri idRoot) { foreach (var relationsRepository in session) { relationsRepository.AddRelation(relation); } GroupSessionHelper.MakeIdsAbsolute(relation, idRoot); }
internal static void Add <T>(this IEnumerable <IProviderRevisionRepository <T> > repositories, Revision <T> item, Uri idRoot) where T : class, IVersionableEntity { foreach (var revisionRepository in repositories) { revisionRepository.AddOrUpdate(item); } GroupSessionHelper.MakeIdsAbsolute(item, idRoot); }
internal static void AddOrUpdate <T>(this IEnumerable <ICoreRepository <T> > repositories, T item, Uri idRoot) where T : class, IReferenceByHiveId { //TODO: Determine which repo is the primary one //TODO: Ensure population of the incoming queue is sorted by Ordinal foreach (var repository in repositories) { repository.AddOrUpdate(item); } GroupSessionHelper.MakeIdsAbsolute(item, idRoot); }
internal static IEnumerable <Revision <T> > GetAll <T>(this IEnumerable <IReadonlyProviderRevisionRepository <T> > readonlyRepositories, HiveId entityId, Uri idRoot, RevisionStatusType revisionStatusType = null) where T : class, IVersionableEntity { //TODO: Determine which repo is the primary one //TODO: Ensure population of the incoming queue is sorted by Ordinal var totalOutput = new HashSet <Revision <T> >(); foreach (var reader in readonlyRepositories) { reader.GetAll <T>(entityId).SkipWhile(SkipAndMerge(reader, totalOutput)).ForEach(x => totalOutput.Add(x)); } return(totalOutput.DistinctBy(x => x.MetaData.Id).Select(x => GroupSessionHelper.MakeIdsAbsolute(x, idRoot))); }
internal static IEnumerable <Revision <TEntity> > GetLatestRevisions <TEntity>(this IEnumerable <IReadonlyProviderRevisionRepository <TEntity> > readonlyRepositories, bool allOrNothing, Uri idRoot, RevisionStatusType revisionStatusType = null, params HiveId[] entityIds) where TEntity : class, IVersionableEntity { Revision <TEntity> returnValue = null; var totalOutput = new HashSet <Revision <TEntity> >(); //TODO: Determine which repo is the primary one //TODO: Ensure population of the incoming queue is sorted by Ordinal foreach (var reader in readonlyRepositories) { reader.GetLatestRevisions <TEntity>(allOrNothing, revisionStatusType, entityIds).SkipWhile(SkipAndMerge(reader, totalOutput)).ForEach(x => totalOutput.Add(x)); } return(totalOutput.DistinctBy(x => x.MetaData.Id).Select(x => GroupSessionHelper.MakeIdsAbsolute(x, idRoot))); }
internal static T ProcessIdsAndGroupRelationProxyDelegate <T>(ICoreReadonlyRelationsRepository groupRepo, Uri idRoot, T returnValue) where T : class, IReferenceByHiveId { if (returnValue == null) { return(null); } GroupSessionHelper.MakeIdsAbsolute(returnValue, idRoot); if (TypeFinder.IsTypeAssignableFrom <IRelatableEntity>(returnValue.GetType())) { var casted = (IRelatableEntity)returnValue; groupRepo.SetGroupRelationProxyLazyLoadDelegate(casted); } return(returnValue); }
internal static IEnumerable <IRelationById> GetDescendentRelations(this IEnumerable <IReadonlyProviderRelationsRepository> session, HiveId ancestorId, Uri idRoot, RelationType relationType = null) { var totalOutput = new HashSet <IRelationById>(); foreach (var readonlyRelationsRepository in session) { if (readonlyRelationsRepository.CanReadRelations) { readonlyRelationsRepository.GetDescendentRelations(ancestorId, relationType) .SkipWhile(SkipAndMergeRelationsFromProviders(readonlyRelationsRepository.ProviderMetadata, totalOutput)) .ForEach(x => totalOutput.Add(x)); } } return(totalOutput.Distinct().Select(x => GroupSessionHelper.CreateRelationByAbsoluteId(x, idRoot))); }
internal static Revision <T> GetLatestRevision <T>(this IEnumerable <IReadonlyProviderRevisionRepository <T> > readonlyRepositories, HiveId hiveId, Uri idRoot, RevisionStatusType revisionStatusType = null) where T : class, IVersionableEntity { Revision <T> returnValue = null; //TODO: Determine which repo is the primary one //TODO: Ensure population of the incoming queue is sorted by Ordinal foreach (var reader in readonlyRepositories) { returnValue = reader.GetLatestRevision <T>(hiveId, revisionStatusType); if (returnValue != null) { break; } } return(GroupSessionHelper.MakeIdsAbsolute(returnValue, idRoot)); }
internal static IRelationById FindRelation(this IEnumerable <IReadonlyProviderRelationsRepository> sessions, HiveId sourceId, HiveId destinationId, Uri idRoot, RelationType relationType = null) { IRelationById result = null; foreach (var readonlyRelationsRepository in sessions) { if (readonlyRelationsRepository.CanReadRelations) { result = readonlyRelationsRepository.FindRelation(sourceId, destinationId, relationType); } if (result != null) { break; } } return(GroupSessionHelper.CreateRelationByAbsoluteId(result, idRoot)); }
internal static IEnumerable <IRelationById> GetAncestorRelations(this IEnumerable <IReadonlyProviderRelationsRepository> allProviderRepositories, HiveId descendentId, Uri idRoot, RelationType relationType = null) { var totalOutput = new HashSet <IRelationById>(); foreach (var relationsRepository in allProviderRepositories) { if (relationsRepository.CanReadRelations) { var provider = relationsRepository; var relations = relationsRepository.RepositoryScopedCache.GetOrCreateTyped("rprr_GetAncestorRelations_" + descendentId + (relationType != null ? relationType.RelationName : "any_relationtype"), () => provider.GetAncestorRelations(descendentId, relationType).ToArray()); relations .SkipWhile(SkipAndMergeRelationsFromProviders(relationsRepository.ProviderMetadata, totalOutput)) .ForEach(x => totalOutput.Add(x)); } } return(totalOutput.Distinct().Select(x => GroupSessionHelper.CreateRelationByAbsoluteId(x, idRoot))); }