List of usage examples for javax.ejb TransactionAttributeType REQUIRED
TransactionAttributeType REQUIRED
To view the source code for javax.ejb TransactionAttributeType REQUIRED.
Click Source Link
From source file:com.flexive.ejb.beans.structure.SelectListEngineBean.java
/** * {@inheritDoc}/*from w w w . jav a2s . c om*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long save(FxSelectListEdit list) throws FxApplicationException { final boolean newList = list.isNew(); boolean changes = newList; long id = list.getId(); if (newList) { id = createList(list); } else { if (list.changes()) { updateList(list); changes = true; } } if (!newList) { //remove selct items that are no longer referenced by this list List<FxSelectListItem> originalItems = CacheAdmin.getEnvironment().getSelectList(list.getId()) .getItems(); List<FxSelectListItem> editedItems = list.getItems(); for (FxSelectListItem i : originalItems) { boolean found = false; for (FxSelectListItem j : editedItems) { if (i.getId() == j.getId()) { found = true; break; } } if (!found) remove(i); } } FxSelectListItemEdit e; long defaultItemId = 0; long currentItemId; if (list.hasDefaultItem()) defaultItemId = list.getDefaultItem().getId(); Map<Long, Long> idMap = null; for (FxSelectListItem item : list.getItems()) { e = (item instanceof FxSelectListItemEdit ? (FxSelectListItemEdit) item : item.asEditable()); if (!e.isNew()) continue; if (idMap == null) idMap = new HashMap<Long, Long>(10); idMap.put(e.getId(), seq.getId(FxSystemSequencer.SELECTLIST_ITEM)); } try { for (FxSelectListItemEdit item : sortItemsByParent(list.getItems())) { e = item; if (newList) { currentItemId = createItem(e, idMap); //get the new created default item id if (defaultItemId < 0 && e.getId() == defaultItemId) defaultItemId = currentItemId; } else if (e.isNew()) { createItem(e, idMap); changes = true; } else if (e.changes()) { //check if the user is permitted to edit this specific item if (FxContext.getUserTicket().isInRole(Role.SelectListEditor) || FxContext.getUserTicket().mayCreateACL(e.getAcl().getId(), -1)) { updateItem(e); changes = true; } else throw new FxNoAccessException("ex.role.notInRole", Role.SelectListEditor.getName()); } } updatePositions(list.getItems(), idMap); updateDefaultItem(id, defaultItemId); if (!changes) { FxSelectListItem orgDef = CacheAdmin.getEnvironment().getSelectList(id).getDefaultItem(); if ((orgDef == null && defaultItemId != 0) || (orgDef != null && defaultItemId <= 0) || (orgDef != null && defaultItemId != 0 && orgDef.getId() != defaultItemId)) changes = true; } try { if (changes) StructureLoader.reload(null); } catch (FxCacheException e1) { EJBUtils.rollback(ctx); throw new FxCreateException(LOG, e1, "ex.cache", e1.getMessage()); } return id; } catch (FxApplicationException fxApp) { ctx.setRollbackOnly(); throw fxApp; } }
From source file:com.flexive.ejb.beans.search.SearchEngineBean.java
/** * {@inheritDoc}/* ww w. j a v a2 s . c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public FxResultSet search(String query, int startIndex, int fetchRows, FxSQLSearchParams params, ResultLocation location, ResultViewType viewType) throws FxApplicationException { try { if (params == null) { params = new FxSQLSearchParams(); } return new SqlSearch(seq, briefcase, treeEngine, query, startIndex, fetchRows, params, resultPreferences, location, viewType).executeQuery(); } catch (FxSqlSearchException exc) { EJBUtils.rollback(ctx); throw exc; } }
From source file:gov.medicaid.screening.dao.impl.NursingLicenseDAOBean.java
/** * Searches for providers with Medical Practice license using the name filter. * * @param criteria the search criteria/*from w w w . j ava2 s. co m*/ * @return the matched results * @throws ParsingException if any parsing errors are encountered * @throws ServiceException for any other exceptions encountered */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public SearchResult<License> searchByName(NursingLicenseSearchCriteria criteria) throws ParsingException, ServiceException { String signature = "NursingLicenseDataAccessImpl#searchByName"; LogUtil.traceEntry(getLog(), signature, new String[] { "criteria" }, new Object[] { criteria }); if (criteria == null) { throw new ServiceException(ErrorCode.MITA10005.getDesc()); } if (Util.isBlank(criteria.getLastName()) && Util.isBlank(criteria.getFirstName())) { throw new ServiceException(ErrorCode.MITA10005.getDesc()); } validateSortOptions(criteria, SORT_COLUMNS); try { SearchResult<License> allResults = getAllResults(criteria, true); SearchResult<License> results = trimResults(allResults, criteria.getPageSize(), criteria.getPageNumber(), SORT_COLUMNS.get(criteria.getSortColumn()), criteria.getSortOrder()); logSearchEntry(criteria); return LogUtil.traceExit(getLog(), signature, results); } catch (ClientProtocolException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (URISyntaxException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (IOException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (ParseException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } }
From source file:gov.medicaid.screening.dao.impl.BBHTLicenseDAOBean.java
/** * Searches for providers with BBHT license using the given criteria. * * @param criteria the search criteria// w w w. j a v a 2s .c o m * @return the matched results * @throws ParsingException if any parsing errors are encountered * @throws ServiceException for any other exceptions encountered */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public SearchResult<License> search(BBHTLicenseSearchCriteria criteria) throws ParsingException, ServiceException { String signature = "BBHTLicenseDataAccessImpl#search"; LogUtil.traceEntry(getLog(), signature, new String[] { "criteria" }, new Object[] { criteria }); if (criteria == null) { throw new ServiceException(ErrorCode.MITA10005.getDesc()); } if (Util.isBlank(criteria.getLastName()) && Util.isBlank(criteria.getFirstName()) && Util.isBlank(criteria.getIdentifier()) && criteria.getLicenseType() == null) { throw new ServiceException(ErrorCode.MITA10005.getDesc()); } boolean byName = false; if (Util.isNotBlank(criteria.getLastName()) || Util.isNotBlank(criteria.getFirstName())) { byName = true; } else { // transform the license type mapping boolean found = false; for (Map.Entry<String, String> type : TYPES.entrySet()) { if (type.getValue().equals(criteria.getLicenseType().getName())) { criteria.getLicenseType().setName(type.getKey()); found = true; } } if (!found) { throw new ServiceException(ErrorCode.MITA10009.getDesc()); } if (Util.isBlank(criteria.getIdentifier())) { throw new ServiceException(ErrorCode.MITA10004.getDesc()); } if (!Util.isDigits(criteria.getIdentifier())) { throw new ServiceException(ErrorCode.MITA10010.getDesc()); } } validateSortOptions(criteria, SORT_COLUMNS); try { SearchResult<License> allResults = getAllResults(criteria, byName); SearchResult<License> results = trimResults(allResults, criteria.getPageSize(), criteria.getPageNumber(), SORT_COLUMNS.get(criteria.getSortColumn()), criteria.getSortOrder()); logSearchEntry(criteria); return LogUtil.traceExit(getLog(), signature, results); } catch (ClientProtocolException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (URISyntaxException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (IOException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } catch (ParseException e) { LogUtil.traceError(getLog(), signature, e); throw new ServiceException(ErrorCode.MITA50001.getDesc(), e); } }
From source file:gov.medicaid.screening.dao.impl.BusinessLienDAOBean.java
/** * Searches for MN business and liens by file number. * * @param criteria the search criteria//www. ja v a 2 s .c o m * @return the matched results * @throws ParsingException if any parsing errors are encountered * @throws ServiceException for any other exceptions encountered */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public SearchResult<ProviderProfile> searchByFileNumber(BusinessLienSearchCriteria criteria) throws ParsingException, ServiceException { String signature = "BusinessLienDataAccessImpl#searchByFileNumber"; LogUtil.traceEntry(getLog(), signature, new String[] { "criteria" }, new Object[] { criteria }); if (criteria == null) { throw new ServiceException(ErrorCode.MITA10005.getDesc()); } if (Util.isBlank(criteria.getFileNumber())) { throw new ServiceException(ErrorCode.MITA10024.getDesc()); } return LogUtil.traceExit(getLog(), signature, search(criteria)); }
From source file:com.sfs.ucm.controller.ProjectPackageAction.java
/** * Add action/*from w w w.j ava 2 s . c o m*/ */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public void add() { this.projectPackage = new ProjectPackage(ModelUtils.getNextIdentifier(this.projectPackages)); }
From source file:gov.nih.nci.caarray.application.GenericDataServiceBean.java
/** * {@inheritDoc}/*from ww w . ja v a 2s .c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void delete(PersistentObject object) { this.projectDao.remove(object); }
From source file:com.flexive.ejb.beans.BriefcaseEngineBean.java
/** * {@inheritDoc}/*from www .j a v a2 s .c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long create(String name, String description, Long aclId) throws FxApplicationException { return create(name, description, aclId, null); }
From source file:com.sfs.ucm.controller.ProjectPackageAction.java
/** * Action: remove object// w ww . j a va 2 s . co m * * @throws UCMException */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public void remove() throws UCMException { try { this.project.removeProjectPackage(projectPackage); em.remove(this.projectPackage); logger.info("deleted {}", this.projectPackage.getName()); this.facesContextMessage.infoMessage("{0} deleted successfully", StringUtils.abbreviate(this.projectPackage.getName(), 25)); // refresh list loadList(); this.selected = false; } catch (Exception e) { throw new UCMException(e); } }
From source file:org.grouter.domain.service.ejb3.RouterBeanService.java
@TransactionAttribute(TransactionAttributeType.REQUIRED) public void createMessage(Message[] messages) { logger.debug("In saveMessage. Number of messages :" + messages.length); if (messages == null) { throw new IllegalArgumentException("Null inparameter"); }// w ww . j a v a 2s .c o m messageDAO = DAOFactory.getFactory(DAOFactory.FactoryType.EJB3_PERSISTENCE).getMessageDAO(); for (Message message : messages) { logger.debug("## Calling dao to create message"); messageDAO.save(message); } }