Search in sources :

Example 1 with EasyCrudM2mService

use of org.summerb.easycrud.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.easycrud.api.dto.relations.Ref) EasyCrudService(org.summerb.easycrud.api.EasyCrudService) HashSet(java.util.HashSet) Set(java.util.Set) DataSet(org.summerb.easycrud.api.dto.datapackage.DataSet) EasyCrudM2mService(org.summerb.easycrud.api.relations.EasyCrudM2mService) PaginatedList(org.summerb.easycrud.api.dto.PaginatedList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) 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.easycrud.api.EasyCrudService)1 PaginatedList (org.summerb.easycrud.api.dto.PaginatedList)1 DataSet (org.summerb.easycrud.api.dto.datapackage.DataSet)1 Ref (org.summerb.easycrud.api.dto.relations.Ref)1 EasyCrudM2mService (org.summerb.easycrud.api.relations.EasyCrudM2mService)1