/** * Loads a list of entities. */ public List<E> list() { LoadContext<E> loadContext = createLoadContext(); return dataManager.loadList(loadContext); }
@Override public <E extends Entity> List<E> loadList(LoadContext<E> context) { context.setJoinTransaction(true); return dataManager.loadList(context); }
@Override public <E extends Entity> List<E> loadList(LoadContext<E> context) { context.setAuthorizationRequired(true); return dataManager.loadList(context); }
@Override public <E extends Entity> List<E> loadList(LoadContext<E> context) { context.setAuthorizationRequired(true); return dataManager.loadList(context); }
@Override @Nonnull public <E extends Entity> List<E> loadList(LoadContext<E> context) { return getDataManager().loadList(context); }
/** * Loads a list of entities. */ public List<E> list() { LoadContext<E> loadContext = createLoadContext(); return loader.dataManager.loadList(loadContext); }
protected Collection<? extends Entity> reloadEntities(Collection<? extends Entity> entities, View view) { List<Object> ids = entities.stream() .map(Entity::getId) .collect(Collectors.toList()); MetaClass metaClass = metadata.getClassNN(view.getEntityClass()); LoadContext.Query query = LoadContext.createQuery("select e from " + metaClass.getName() + " e where e.id in :ids") .setParameter("ids", ids); LoadContext<? extends Entity> ctx = LoadContext.create(view.getEntityClass()) .setQuery(query) .setView(view); return dataManager.loadList(ctx); }
/** * Return list of reports, available for user * * @param user - caller user */ public List<BIReport> getAvailableReports(@Nullable User user) { LoadContext<BIReport> ctx = new LoadContext<>(BIReport.class); ctx.setLoadDynamicAttributes(false); ctx.setView("biReport-edit-view"); ctx.setQueryString("select r from cubabi$BIReport r"); List<BIReport> reports = dataManager.loadList(ctx); reports = applySecurityPolicies(user, reports); return reports; }
protected List<com.haulmont.cuba.core.entity.Config> loadDbContent() { LoadContext<com.haulmont.cuba.core.entity.Config> loadContext = LoadContext.create(com.haulmont.cuba.core.entity.Config.class).setQuery( LoadContext.createQuery("select c from sys$Config c") ).setView("appProperties"); return dataManager.loadList(loadContext); }
protected List<ProcDefinition> findProcDefinitionsByModel(ProcModel model) { LoadContext<ProcDefinition> ctx = LoadContext.create(ProcDefinition.class); ctx.setQueryString( "select pd from bpm$ProcDefinition pd " + "where pd.model.id = :modelId order by pd.name, pd.deploymentDate desc") .setParameter("modelId", model.getId()); return dataManager.loadList(ctx); }
private List<Tenant> createOptionList() { return dataManager.loadList(LoadContext.create(Tenant.class) .setQuery(LoadContext.createQuery("select e from cubasdbmt$Tenant e")) .setView("tenant-with-group")); }
protected List<ProcDefinition> getProcDefinitionsByName(String name) { LoadContext ctx = new LoadContext(ProcDefinition.class); ctx.setQuery(new LoadContext.Query("select pd from bpm$ProcDefinition pd where pd.name = :name") .setParameter("name", name)); return dataManager.loadList(ctx); }
protected void loadEntities(MetaClass metaClass) { LoadContext loadContext = LoadContext.create(metaClass.getJavaClass()) .setQuery(LoadContext.createQuery(format("select e from %s e", metaClass.getName()))); List entities = dataManager.loadList(loadContext); entitiesLookup.setOptionsList(entities); }
public String loadReportsList() { checkCanReadEntity(metadata.getClassNN(Report.class)); LoadContext<Report> loadContext = new LoadContext<>(Report.class); loadContext.setView( new View(Report.class) .addProperty("id") .addProperty("name") .addProperty("code")) .setQueryString("select r from report$Report r where r.restAccess = true"); reportSecurityManager.applySecurityPolicies(loadContext, null, userSessionSource.getUserSession().getCurrentOrSubstitutedUser()); List<Report> reports = dataManager.loadList(loadContext); List<ReportInfo> objects = reports.stream() .map(this::mapToReportInfo) .collect(Collectors.toList()); return createGson().toJson(objects); }
protected List<Entity> loadEntityList(String[] ids) { Metadata metadata = AppBeans.get(Metadata.class); MetaClass metaClass = metadata.getSession().getClassNN(javaClass); LoadContext ctx = new LoadContext(javaClass); LoadContext.Query query = ctx.setQueryString("select e from " + metaClass.getName() + " e where e.id in :ids"); query.setParameter("ids", Arrays.asList(ids)); DataManager dataManager = AppBeans.get(DataManager.class); return dataManager.loadList(ctx); }
protected List<Entity> loadItemsWithDirectKey(LoadDescriptor ld) { LoadContext.Query query = new LoadContext.Query( String.format("select e from %s e where e.%s in :ids", ld.getMetaClass(), metadataTools.getPrimaryKeyName(ld.getMetaClass()))); List<Object> ids = ld.getSelectedItems().stream() .map(Entity::getId) .collect(Collectors.toList()); query.setParameter("ids", ids); LoadContext<Entity> lc = new LoadContext<>(ld.getMetaClass()); lc.setSoftDeletion(false); lc.setQuery(query); lc.setView(ld.getView()); lc.setLoadDynamicAttributes(ld.isLoadDynamicAttributes()); return dataManager.secure().loadList(lc); } }
@Override public List<SessionLogEntry> getAllSessionLogRecords(UUID userSessionId) { return authentication.withSystemUser(() -> { LoadContext<SessionLogEntry> loadContext = LoadContext.create(SessionLogEntry.class) .setView(SessionLogEntry.DEFAULT_VIEW) .setQuery( createQuery("select e from sec$SessionLogEntry e where e.sessionId = :sid order by e.startedTs asc") .setParameter("sid", userSessionId) ); return dataManager.loadList(loadContext); }); }
@Override public List<UserSubstitution> getSubstitutedUsers(UUID userId) { LoadContext<UserSubstitution> ctx = new LoadContext<>(UserSubstitution.class); LoadContext.Query query = ctx.setQueryString("select us from sec$UserSubstitution us " + "where us.user.id = :userId and (us.endDate is null or us.endDate >= :currentDate) " + "and (us.startDate is null or us.startDate <= :currentDate) " + "and (us.substitutedUser.active = true or us.substitutedUser.active is null) order by us.substitutedUser.name"); query.setParameter("userId", userId); query.setParameter("currentDate", timeSource.currentTimestamp()); ctx.setView("app"); return dataManager.loadList(ctx); } }
@Authenticated public String updateSecurityIndex() { LoadContext<Report> ctx = new LoadContext<>(Report.class); ctx.setLoadDynamicAttributes(true); ctx.setView("report.edit"); ctx.setQueryString("select r from report$Report r"); List<Report> resultList = dataManager.loadList(ctx); for (Report report : resultList) { reportingApi.storeReportEntity(report); } return "Index migrated successfully"; } }
protected List<Entity> getQueryResult(String query) { MetaClass metaClass = entitiesMetaClasses.getValue(); if (metaClass == null) { return null; } String view = entityViews.getValue(); LoadContext<Entity> loadContext = new LoadContext<>(metaClass); loadContext.setView(view); Integer limit = entityLimitField.getValue(); if (limit == null) { loadContext.setQueryString(query); } else { loadContext.setQueryString(query).setMaxResults(limit); } return dataManager.loadList(loadContext); }