List of usage examples for org.apache.ibatis.session SqlSession rollback
void rollback();
From source file:net.cbtltd.server.ProductService.java
/** * Executes the ProductDelete action to delete a Product instance. * This deletes the relation between the product and the current organization, not the product instance. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.//from www . j a v a 2 s .c om */ public final Product execute(SqlSession sqlSession, ProductDelete action) { try { RelationService.delete(sqlSession, Relation.ORGANIZATION_PRODUCT, action.getOrganizationid(), action.getId()); } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return null; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the ProductCopy action to copy a Product instance. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w w w .j a v a 2s.c o m*/ */ public final Product execute(SqlSession sqlSession, ProductCopy action) { try { action.setName(Model.BLANK); // action.setPartofid(null); final String oldId = action.getId(); sqlSession.getMapper(ProductMapper.class).create(action); final String newId = action.getId(); TextService.copy(sqlSession, NameId.Type.Product.name(), oldId, newId, action); sqlSession.getMapper(PriceMapper.class).copy(new NameId(oldId, newId)); sqlSession.getMapper(YieldMapper.class).copy(new NameId(oldId, newId)); RelationService.replace(sqlSession, Relation.PRODUCT_VALUE, newId, action.getValues()); RelationService.replace(sqlSession, Relation.PRODUCT_ATTRIBUTE, newId, action.getAttributemap()); RelationService.replace(sqlSession, Relation.ORGANIZATION_PRODUCT, action.getOrganizationid(), newId); //TODO: copy product values /*ArrayList<NameId> images = sqlSession.getMapper(TextMapper.class).imagesbynameid(new NameId(NameId.Type.Product.name(), oldId)); List<NameId> images = ImageService.getProductRegularImageURLsAndDescription(sqlSession, oldId); UploadFileService.copyImages(sqlSession, NameId.Type.Product, newId, Language.EN, (ArrayList<NameId>)images);*/ //LOG.debug("ProductCopy images " + oldId + " " + newId + " " + images); action.setImageurls(new ArrayList<String>()); action.setProductImageRootLocation(ImageService.getProductImageLocation(sqlSession, action)); } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return action; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the ProductList action to read a list of Product instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from ww w. j a va 2 s .co m*/ */ public final Table<Product> execute(SqlSession sqlSession, ProductList action) { Table<Product> table = new Table<Product>(); try { table.setDatasize(sqlSession.getMapper(ProductMapper.class).count(action)); table.setValue(sqlSession.getMapper(ProductMapper.class).list(action)); } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the ProductTable action to read a list of component Product instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.// w w w. j a v a 2 s .com */ public final Table<Product> execute(SqlSession sqlSession, ProductTable action) { LOG.debug("ProductTable " + action); Table<Product> table = new Table<Product>(); try { table.setValue(sqlSession.getMapper(ProductMapper.class).componentlist(action.getId())); } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } LOG.debug("ProductTable " + table); return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the NameIdAction action to read a list of product NameId instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w ww . j ava 2 s. co m*/ */ public final Table<NameId> execute(SqlSession sqlSession, NameIdAction action) { LOG.debug("NameIdAction " + action); Table<NameId> table = new Table<NameId>(); try { if (action.isSuggested()) { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidbyid(action)); } else { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidbyname(action)); } } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } LOG.debug("NameIdAction " + table); return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the NoOfflineNameId action to check that a Product instance is not off line. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.//from w ww. j a v a 2 s. c om */ public final Table<NameId> execute(SqlSession sqlSession, NoOfflineNameId action) { Table<NameId> table = new Table<NameId>(); try { if (action.isSuggested()) { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidbyid(action)); } else { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidnopartof(action)); } } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the NoPartofNameId action to check that a Product instance is not part of itself. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.//from w ww. j a v a 2 s .c om */ public final Table<NameId> execute(SqlSession sqlSession, NoPartofNameId action) { Table<NameId> table = new Table<NameId>(); try { if (action.isSuggested()) { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidbyid(action)); } else { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidnopartof(action)); } } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the ProductUnspsc action to read the UNSPSC code of a Product instance. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from ww w . j a v a 2s .c o m*/ */ public final Table<NameId> execute(SqlSession sqlSession, ProductUnspsc action) { Table<NameId> table = new Table<NameId>(); try { if (action.isSuggested()) { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidbyid(action)); } else { table.setValue(sqlSession.getMapper(UnspscMapper.class).nameidbyname(action)); } } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the NameIdType action to read a list of product asset type NameId instances. * NOTE this does not get the product types but the types of its assets! * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.// w w w . java 2 s . c o m */ public final Table<NameId> execute(SqlSession sqlSession, NameIdType action) { Table<NameId> table = new Table<NameId>(); try { table.setValue(sqlSession.getMapper(ProductMapper.class).nameidtype(action)); } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } return table; }
From source file:net.cbtltd.server.ProductService.java
/** * Executes the NameIdAction action to read a list of product NameId instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.// w w w. j av a2s . c om */ public final Table<Position> execute(SqlSession sqlSession, ProductPositions action) { LOG.debug("ProductPositions " + action); Table<Position> table = new Table<Position>(); try { table.setValue(sqlSession.getMapper(ProductMapper.class).positions(action)); } catch (Throwable x) { sqlSession.rollback(); MonitorService.log(x); } LOG.debug("ProductPositions " + table); return table; }