LoadContext<E> createLoadContext() { LoadContext<E> loadContext = LoadContext.create(loader.entityClass).setId(id); loader.initCommonLoadContextParameters(loadContext); return loadContext; }
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<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 LoadContext getLoadContextForForEntityLoadInfo(MetaClass metaClass, Object entityId) { LoadContext loadContext = LoadContext.create(metaClass.getJavaClass()); loadContext .setId(entityId); return loadContext; }
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); }
protected LoadContext getLoadContextForForEntityLoadInfo(MetaClass metaClass, Object entityId) { LoadContext loadContext = LoadContext.create(metaClass.getJavaClass()); loadContext .setId(entityId); return loadContext; }
LoadContext<E> createLoadContext() { LoadContext<E> loadContext = LoadContext.create(entityClass); initCommonLoadContextParameters(loadContext); String entityName = AppBeans.get(Metadata.class).getClassNN(entityClass).getName(); String queryString = String.format("select e from %s e", entityName); loadContext.setQuery(LoadContext.createQuery(queryString)); return 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); }
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); }
@Nullable protected ProcModel findModelByName(String modelName) { View view = new View(ProcModel.class) .addProperty("name") .addProperty("actModelId"); LoadContext<ProcModel> ctx = LoadContext.create(ProcModel.class).setView(view); ctx.setQueryString("select m from bpm$ProcModel m where m.name = :name") .setParameter("name", modelName); return dataManager.load(ctx); }
@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); }); }
protected Entity loadEntity(EntityParameterValue parameter) { Class entityClass = metadata.getClass(parameter.getMetaClassName()).getJavaClass(); LoadContext loadContext = LoadContext.create(entityClass) .setId(java.util.UUID.fromString(parameter.getEntityId())) .setView(parameter.getViewName()); return dataManager.load(loadContext); }
@Override public SessionLogEntry getLastSessionLogRecord(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 desc") .setParameter("sid", userSessionId) .setMaxResults(1) ); return dataManager.load(loadContext); }); }
@Override public void changeGroupParent(UUID groupId, UUID newParentId) { checkUpdatePermission(Group.class); DataManager dataManager = this.dataManager.secure(); Group group = dataManager.load(LoadContext.create(Group.class) .setId(groupId) .setView(GROUP_COPY_VIEW)); LoadContext<Group> context = LoadContext.create(Group.class) .setId(newParentId) .setView(GROUP_COPY_VIEW); Group newParent = newParentId != null ? dataManager.load(context) : null; if (group != null) { group.setParent(newParent); } dataManager.commit(group); }
LoadContext<E> createLoadContext() { LoadContext<E> loadContext = LoadContext.create(loader.entityClass); loader.initCommonLoadContextParameters(loadContext); LoadContext.Query query = LoadContext.createQuery(queryString); for (Map.Entry<String, Object> entry : parameters.entrySet()) { if (noConversionParams.contains(entry.getKey())) query.setParameter(entry.getKey(), entry.getValue(), false); else query.setParameter(entry.getKey(), entry.getValue()); } loadContext.setQuery(query); loadContext.getQuery().setCondition(condition); loadContext.getQuery().setFirstResult(firstResult); loadContext.getQuery().setMaxResults(maxResults); loadContext.getQuery().setCacheable(cacheable); return loadContext; }
/** * Load filter entities from database and saves them in {@code filterEntities} collection. */ protected void loadFilterEntities() { LoadContext<FilterEntity> ctx = LoadContext.create(FilterEntity.class); ctx.setView("app"); ctx.setQueryString("select f from sec$Filter f left join f.user u " + "where f.componentId = :component and (u.id = :userId or u is null) order by f.name") .setParameter("component", ComponentsHelper.getFilterComponentPath(filter)) .setParameter("userId", userSessionSource.getUserSession().getCurrentOrSubstitutedUser().getId()); filterEntities = new ArrayList<>(dataService.loadList(ctx)); }
protected Dashboard loadDashboardByCode(String code) { LoadContext<PersistentDashboard> loadContext = LoadContext.create(PersistentDashboard.class) .setQuery(LoadContext.createQuery("select d from dashboard$PersistentDashboard d where d.code = :code") .setParameter("code", code)) .setView("_local"); PersistentDashboard entity = dataManager.load(loadContext); if (entity == null || entity.getDashboardModel() == null) { return null; } return jsonConverter.dashboardFromJson(entity.getDashboardModel()); }
public LoadContext<E> createLoadContext() { LoadContext<E> loadContext = LoadContext.create(container.getEntityMetaClass().getJavaClass()); if (entityId != null) { loadContext.setId(entityId); } else { LoadContext.Query query = loadContext.setQueryString(this.query); query.setCondition(condition); query.setParameters(parameters); } loadContext.setView(resolveView()); loadContext.setSoftDeletion(softDeletion); loadContext.setLoadDynamicAttributes(loadDynamicAttributes); return loadContext; }
@Override public EntitySnapshot getLastEntitySnapshot(Entity entity) { checkCompositePrimaryKey(entity); MetaClass metaClass = extendedEntities.getOriginalOrThisMetaClass(entity.getMetaClass()); View view = metadata.getViewRepository().getView(EntitySnapshot.class, "entitySnapshot.browse"); LoadContext<EntitySnapshot> lx = LoadContext.create(EntitySnapshot.class).setQuery(LoadContext .createQuery(format("select e from sys$EntitySnapshot e where e.entityMetaClass = :metaClass and" + " e.entity.%s = :entityId order by e.snapshotDate desc", referenceToEntitySupport.getReferenceIdPropertyName(metaClass))) .setParameter("metaClass", metaClass.getName()) .setParameter("entityId", referenceToEntitySupport.getReferenceId(entity)) .setMaxResults(1)) .setView(view); return dataManager.load(lx); }
@Override public LoadContext<E> createLoadContext() { LoadContext<E> loadContext = LoadContext.create(container.getEntityMetaClass().getJavaClass()); LoadContext.Query query = loadContext.setQueryString(this.query); query.setCondition(condition); query.setSort(sort); query.setParameters(parameters); query.setCacheable(cacheable); if (firstResult > 0) query.setFirstResult(firstResult); if (maxResults < Integer.MAX_VALUE) query.setMaxResults(maxResults); loadContext.setView(resolveView()); loadContext.setSoftDeletion(softDeletion); loadContext.setLoadDynamicAttributes(loadDynamicAttributes); return loadContext; }