Search in sources :

Example 1 with EasyCrudM2mService

use of org.summerb.approaches.jdbccrud.api.relations.EasyCrudM2mService in project summerb by skarpushin.

the class DataSetLoaderImpl method loadManyToManyReferences.

private ManyToManyRefToReferenceesMap loadManyToManyReferences(Map<Ref, Set<Object>> manyToManyReferences) {
    // NOTE: Queries to same types of referencees are not grouped. Should we
    // impl this like we did for one2many?
    ManyToManyRefToReferenceesMap ret = new ManyToManyRefToReferenceesMap();
    for (Entry<Ref, Set<Object>> refToReferencersEntry : manyToManyReferences.entrySet()) {
        EasyCrudService m2mServiceTmp = easyCrudServiceResolver.resolveByEntityType(refToReferencersEntry.getKey().getM2mEntity());
        Preconditions.checkState(m2mServiceTmp instanceof EasyCrudM2mService);
        EasyCrudM2mService m2mService = (EasyCrudM2mService) m2mServiceTmp;
        Map<Object, List<HasId>> referenceeMap = m2mService.findReferenceeByReferencers(refToReferencersEntry.getValue());
        ret.put(refToReferencersEntry.getKey(), referenceeMap);
    }
    return ret;
}
Also used : Ref(org.summerb.approaches.jdbccrud.api.dto.relations.Ref) EasyCrudService(org.summerb.approaches.jdbccrud.api.EasyCrudService) HashSet(java.util.HashSet) Set(java.util.Set) DataSet(org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet) EasyCrudM2mService(org.summerb.approaches.jdbccrud.api.relations.EasyCrudM2mService) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) PaginatedList(org.summerb.approaches.jdbccrud.api.dto.PaginatedList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 EasyCrudService (org.summerb.approaches.jdbccrud.api.EasyCrudService)1 PaginatedList (org.summerb.approaches.jdbccrud.api.dto.PaginatedList)1 DataSet (org.summerb.approaches.jdbccrud.api.dto.datapackage.DataSet)1 Ref (org.summerb.approaches.jdbccrud.api.dto.relations.Ref)1 EasyCrudM2mService (org.summerb.approaches.jdbccrud.api.relations.EasyCrudM2mService)1