protected TgwEntity getEntity(String domainName, String entityDisplayName) { ModelService entityService = (ModelService) getService(ModelService.class); TgwEntity entity = entityService.getEntityByDisplayName(domainName, entityDisplayName); if (entity == null) { entity = entityService.getEntity(domainName, entityDisplayName); } return entity; }
public void run(Object obj) { DAOService daoService = (DAOService) SingletonS2ContainerFactory .getContainer().getComponent(DAOService.class); ModelService entityService = (ModelService) SingletonS2ContainerFactory .getContainer().getComponent(ModelService.class); String siteName = TgwContext.getSiteName(); HttpServletRequest request = TgwContext.getRequest(); Map map = TgwContext.getEntityNameMapFromRequest(request); String idStr = (String) map.get(entityName); if (idStr == null) { return; } Long id = Long.valueOf(idStr); if (id.longValue() > 0) { TgwEntity entity = entityService.getEntity(siteName, entityName); daoService.getDAO(entity).delete(id); } } }
public void run(Object obj) { DAOService daoService = (DAOService) SingletonS2ContainerFactory .getContainer().getComponent(DAOService.class); ModelService entityService = (ModelService) SingletonS2ContainerFactory .getContainer().getComponent(ModelService.class); String siteName = TgwContext.getSiteName(); TgwEntity entity = entityService.getEntity(siteName, entityName); DaoMethod daoMethod = daoService.getDAO(entity) .getMethod(updateDaoName); // get id directly from httprequest HttpServletRequest request = TgwContext.getRequest(); Map<String, String> map = TgwContext .getEntityNameMapFromRequest(request); String idStr = map.get(entityName); if (idStr == null) { return; } Long id = Long.valueOf(idStr); // Long id = TgwPluginUtils.getEntityId(entity); if (id != null && id.longValue() > 0) { // ignore logic daoMethod.evaluate(id); } } }
public boolean test(Object obj) { // Ignore Input "obj" ModelService entityService = (ModelService) SingletonS2ContainerFactory .getContainer().getComponent(ModelService.class); DAOService daoService = (DAOService) SingletonS2ContainerFactory .getContainer().getComponent(DAOService.class); String domainName = TgwContext.getDomainName(); // TgwEntity entity = entityService.getEntity(siteName, entityName); TgwEntity entity = entityService.getEntity(domainName, entityName); EntityDAO dao = daoService.getDAO(entity); Object ret = (Object) dao.getMethod(aggregationFuncName).evaluate(); Double testValue = null; if(ret instanceof Integer){ double doubleValue = ((Integer)ret).doubleValue(); testValue = new Double(doubleValue); }else{ testValue = (Double)ret; } BinaryPredicate predicate = Op.getInstance(getOpcode()); return predicate.test(testValue, value); } }
private TgwUser retrieveUser(SiteConfig siteConfig, String username) { TgwUser user = null; if (siteConfig.isUserStoreDatabase()) { TgwEntity userEntity = modelService.getEntity(siteConfig.getName(), SecurityUtils.getUserEntityName()); Object userBean = dataService.loadByValue(userEntity, SecurityUtils .getUserColumnUsername(), username); user = new TgwJDBCUser(userBean, siteConfig.getName()); } else { String userdn = directoryService.buildUserDN(username); user = directoryService.getUser(userdn); } return user; }