private TeamCalCache getTeamCalCache() { return ApplicationContextProvider.getApplicationContext().getBean(TeamCalCache.class); } }
private static UserXmlPreferencesCache getUserXmlPreferencesCache() { return ApplicationContextProvider.getApplicationContext().getBean(UserXmlPreferencesCache.class); } }
private static AddressbookDao getAddressbookDao() { return ApplicationContextProvider.getApplicationContext().getBean(AddressbookDao.class); } }
private static ConfigurationService getConfigService() { if (LogoServlet.configService == null) { LogoServlet.configService = ApplicationContextProvider.getApplicationContext() .getBean(ConfigurationService.class); } return LogoServlet.configService; } }
private AddressbookDao getAddressbookDao() { return ApplicationContextProvider.getApplicationContext().getBean(AddressbookDao.class); } }
@Override public UpdateRunningStatus runUpdate() { DatabaseService databaseService = ApplicationContextProvider.getApplicationContext() .getBean(DatabaseService.class); // Updating the schema databaseService.updateSchema(); return UpdateRunningStatus.DONE; } };
private static Set<String> getSearchFields(Class<?> clazz, String[] additionalSearchFields) { PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); Set<String> ret = emf.getSearchableTextFieldsForEntity(clazz); if (additionalSearchFields == null) { return ret; } for (String addf : additionalSearchFields) { if (ret.contains(addf) == false) { LOG.warn("Searchfield added: " + clazz.getName() + "." + addf); ret.add(addf); } } return ret; }
public static void updated(BaseDO<?> oldo, BaseDO<?> newo) { long begin = System.currentTimeMillis(); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); emf.runInTrans((emgr) -> { EmgrUpdateCopyFilterEvent event = new EmgrUpdateCopyFilterEvent(emgr, oldo.getClass(), oldo.getClass(), oldo, newo, true); new HistoryUpdateCopyFilterEventListener().onEvent(event); return null; }); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.updated took: " + (end - begin) + " ms."); }
protected static ModificationStatus getModificationStatus(final ModificationStatus currentStatus, final BaseDO<?> src, final String modifiedField) { HistoryService historyService = HistoryServiceManager.get().getHistoryService(); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); if (currentStatus == ModificationStatus.MAJOR || src instanceof AbstractHistorizableBaseDO == false || historyService.getNoHistoryProperties(emf, src.getClass()) .contains(modifiedField) == false) { return ModificationStatus.MAJOR; } return ModificationStatus.MINOR; }
public static void inserted(BaseDO<?> ob) { long begin = System.currentTimeMillis(); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); emf.runInTrans((emgr) -> { EmgrAfterInsertedEvent event = new EmgrAfterInsertedEvent(emgr, ob); new HistoryEmgrAfterInsertedEventHandler().onEvent(event); return null; }); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.inserted took: " + (end - begin) + " ms."); }
public static List<? extends HistoryEntry> getHistoryEntries(BaseDO<?> ob) { long begin = System.currentTimeMillis(); HistoryService histservice = HistoryServiceManager.get().getHistoryService(); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); List<? extends HistoryEntry> ret = emf.runInTrans((emgr) -> { return histservice.getHistoryEntries(emgr, ob); }); List<? extends HistoryEntry> nret = ret.stream() .sorted((e1, e2) -> e2.getModifiedAt().compareTo(e1.getModifiedAt())).collect(Collectors.toList()); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.getHistoryEntries took: " + (end - begin) + " ms."); return nret; }
/** * This method will be called by CacheHelper and is synchronized via getData(); */ @Override protected void refresh() { log.info("Initializing TeamCalCache ..."); TeamCalDao dao = ApplicationContextProvider.getApplicationContext().getBean(TeamCalDao.class); if (dao == null || teamCalRight == null) { teamCalRight = (TeamCalRight) userRights.getRight(UserRightId.PLUGIN_CALENDAR); } // This method must not be synchronized because it works with a new copy of maps. final Map<Integer, TeamCalDO> map = new HashMap<Integer, TeamCalDO>(); final List<TeamCalDO> list = dao.internalLoadAll(); for (final TeamCalDO cal : list) { TeamCalDO put = map.put(cal.getId(), cal); if (put != null) { log.info("Adding team cal with id: " + cal.getId() + " to cache."); } } this.calendarMap = map; log.info("Initializing of TeamCalCache done."); } }
public static void createHistoryEntry(Object entity, Number id, String user, String property, Class<?> valueClass, Object oldValue, Object newValue) { long begin = System.currentTimeMillis(); String oldVals = histValueToString(valueClass, oldValue); String newVals = histValueToString(valueClass, newValue); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); emf.runInTrans((emgr) -> { HistoryServiceManager.get().getHistoryService().insertManualEntry(emgr, EntityOpType.Update, entity.getClass().getName(), id, user, property, valueClass.getName(), oldVals, newVals); return null; }); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.createHistoryEntry took: " + (end - begin) + " ms."); }
public static void prepareInsert(ExtendedBaseDO<?> dbObj) { PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); emf.runInTrans((emgr) -> { EmgrInitForInsertEvent nev = new EmgrInitForInsertEvent(emgr, dbObj); new InitCreatedStdRecordFieldsEventHandler().onEvent(nev); return null; }); }
public static void prepareUpdate(ExtendedBaseDO<?> dbObj) { PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); emf.runInTrans((emgr) -> { EmgrInitForUpdateEvent nev = new EmgrInitForUpdateEvent(emgr, dbObj); new InitUpdateStdRecordFieldsEventHandler().onEvent(nev); return null; }); }
final PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); final ModificationStatus result = emf.runInTrans((emgr) -> { final Map<Serializable, HistoryProperties> props = new HashMap<>();
/** * @param user * @return List of all projects of which the given user is member of the project manager group. */ public static Collection<ProjektDO> getProjectsOfManager(final PFUserDO user) { final Collection<ProjektDO> result = new LinkedList<ProjektDO>(); final ProjektFilter filter = new ProjektFilter(); if (projektDao == null) { projektDao = ApplicationContextProvider.getApplicationContext().getBean(ProjektDao.class); } final List<ProjektDO> projects = projektDao.getList(filter); if (CollectionUtils.isEmpty(projects) == true) { return result; } final UserGroupCache userGroupCache = TenantRegistryMap.getInstance().getTenantRegistry().getUserGroupCache(); for (final ProjektDO project : projects) { final Integer groupId = project.getProjektManagerGroupId(); if (groupId == null) { // No manager group defined. continue; } if (userGroupCache.isUserMemberOfGroup(user, groupId) == false) { continue; } result.add(project); } return result; } }
private void initActualTenant() { if (ThreadLocalUserContext.getUserContext() == null) { return; } UserContext userContext = ThreadLocalUserContext.getUserContext(); TenantService tenantService = ApplicationContextProvider.getApplicationContext().getBean(TenantService.class); PFUserDO user = userContext.getUser(); if (user.getId() != null && tenantService.isMultiTenancyAvailable() == true) { // Try to find the last used tenant of the user: final Integer currentTenantId = (Integer) UserPreferencesHelper.getEntry(USER_PREF_KEY_CURRENT_TENANT); if (currentTenantId != null) { setCurrentTenant(tenantService.getTenant(currentTenantId)); } else { final Collection<TenantDO> tenants = tenantService.getTenantsOfUser(user.getId()); if (CollectionUtils.isNotEmpty(tenants) == true) { setCurrentTenant(tenants.iterator().next()); } } } }
/** * * @param filter * @param ignoreTenant default is false. */ public QueryFilter(final BaseSearchFilter filter, final boolean ignoreTenant) { if (filter == null) { this.filter = new BaseSearchFilter(); } else { this.filter = filter; } TenantService tenantService = ApplicationContextProvider.getApplicationContext().getBean(TenantService.class); if (ignoreTenant == false && tenantService.isMultiTenancyAvailable() == true) { final UserContext userContext = ThreadLocalUserContext.getUserContext(); final TenantDO currentTenant = userContext.getCurrentTenant(); if (currentTenant != null) { if (currentTenant.isDefault() == true) { this.add(Restrictions.or(Restrictions.eq("tenant", userContext.getCurrentTenant()), Restrictions.isNull("tenant"))); } else { this.add(Restrictions.eq("tenant", userContext.getCurrentTenant())); } } } }
final ApplicationContext appContext = ApplicationContextProvider.getApplicationContext(); if (appContext == null) { log.error("ApplicationContext not available!");