List of usage examples for org.apache.ibatis.session SqlSession getMapper
<T> T getMapper(Class<T> type);
From source file:com.bibisco.manager.SceneManager.java
License:GNU General Public License
public static void move(Integer pIntIdScene, Integer pIntDestPosition) { mLog.debug("Start move(Integer, Integer)"); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/* w ww .j a v a2 s . c om*/ // get scene to update ScenesMapper lScenesMapper = lSqlSession.getMapper(ScenesMapper.class); Scenes lScenes = lScenesMapper.selectByPrimaryKey(pIntIdScene.longValue()); Integer pIntSourcePosition = lScenes.getPosition(); if (pIntSourcePosition.intValue() != pIntDestPosition.intValue()) { // update scene position with fake position to preserve unique index before shift lScenes.setPosition(-1); lScenesMapper.updateByPrimaryKey(lScenes); // update other scenes' position Integer lIntStartPosition; Integer lIntEndPosition; if (pIntSourcePosition > pIntDestPosition) { lIntStartPosition = pIntDestPosition; lIntEndPosition = pIntSourcePosition; lScenesMapper.shiftUp(lIntStartPosition, lIntEndPosition, lScenes.getIdChapter()); } else { lIntStartPosition = pIntSourcePosition; lIntEndPosition = pIntDestPosition; lScenesMapper.shiftDown(lIntStartPosition, lIntEndPosition, lScenes.getIdChapter()); } // update scene position lScenes.setPosition(pIntDestPosition); lScenesMapper.updateByPrimaryKey(lScenes); lSqlSession.commit(); } } catch (Throwable t) { mLog.error(t); lSqlSession.rollback(); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End move(Integer, Integer)"); }
From source file:com.bibisco.manager.SceneManager.java
License:GNU General Public License
public static void save(SceneDTO pSceneDTO) { mLog.debug("Start save(SceneDTO)"); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/*from w ww .ja v a 2 s . co m*/ Scenes lScenes = new Scenes(); lScenes.setIdScene(pSceneDTO.getIdScene().longValue()); lScenes.setPosition(pSceneDTO.getPosition()); lScenes.setDescription(pSceneDTO.getDescription()); lScenes.setIdChapter(pSceneDTO.getIdChapter()); lScenes.setTaskStatus(pSceneDTO.getTaskStatus() != null ? pSceneDTO.getTaskStatus().getValue() : null); ScenesMapper lScenesMapper = lSqlSession.getMapper(ScenesMapper.class); lScenesMapper.updateByPrimaryKeySelective(lScenes); lSqlSession.commit(); } catch (Throwable t) { mLog.error(t); lSqlSession.rollback(); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End save(SceneDTO)"); }
From source file:com.bibisco.manager.SceneManager.java
License:GNU General Public License
public static void save(SceneRevisionDTO pSceneRevisionDTO) { mLog.debug("Start save(SceneDTO)"); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {//w w w . j a v a2 s.c om Scenes lScenes = new Scenes(); lScenes.setIdScene(pSceneRevisionDTO.getIdScene().longValue()); lScenes.setPosition(pSceneRevisionDTO.getPosition()); lScenes.setTaskStatus( pSceneRevisionDTO.getTaskStatus() != null ? pSceneRevisionDTO.getTaskStatus().getValue() : null); ScenesMapper lScenesMapper = lSqlSession.getMapper(ScenesMapper.class); lScenesMapper.updateByPrimaryKeySelective(lScenes); SceneRevisions lSceneRevisions = new SceneRevisions(); lSceneRevisions.setIdScene(pSceneRevisionDTO.getIdScene()); lSceneRevisions.setIdSceneRevision(pSceneRevisionDTO.getIdRevision().longValue()); lSceneRevisions.setRevisionNumber(pSceneRevisionDTO.getRevision()); lSceneRevisions.setSelected("Y"); lSceneRevisions.setIdLocation(pSceneRevisionDTO.getIdLocation()); lSceneRevisions.setPointOfView( pSceneRevisionDTO.getPointOfView() != null ? pSceneRevisionDTO.getPointOfView().getValue() : null); lSceneRevisions.setPointOfViewIdCharacter(pSceneRevisionDTO.getIdCharacterPointOfView()); lSceneRevisions.setScene(pSceneRevisionDTO.getText()); lSceneRevisions.setSceneDate(pSceneRevisionDTO.getSceneDate()); lSceneRevisions.setWords(pSceneRevisionDTO.getWordCount()); lSceneRevisions.setCharacters(pSceneRevisionDTO.getCharacterCount()); SceneRevisionsMapper lSceneRevisionsMapper = lSqlSession.getMapper(SceneRevisionsMapper.class); lSceneRevisionsMapper.updateByPrimaryKeyWithBLOBs(lSceneRevisions); // save characters SceneRevisionCharactersMapper lSceneRevisionCharactersMapper = lSqlSession .getMapper(SceneRevisionCharactersMapper.class); SceneRevisionCharactersExample lSceneRevisionCharactersExample = new SceneRevisionCharactersExample(); lSceneRevisionCharactersExample.createCriteria() .andIdSceneRevisionEqualTo((pSceneRevisionDTO.getIdRevision())); lSceneRevisionCharactersMapper.deleteByExample(lSceneRevisionCharactersExample); if (pSceneRevisionDTO.getCharacters() != null && pSceneRevisionDTO.getCharacters().size() > 0) { for (Integer lIntIdCharacter : pSceneRevisionDTO.getCharacters()) { SceneRevisionCharactersKey lSceneRevisionCharactersKey = new SceneRevisionCharactersKey(); lSceneRevisionCharactersKey.setIdCharacter(lIntIdCharacter); lSceneRevisionCharactersKey.setIdSceneRevision(pSceneRevisionDTO.getIdRevision()); lSceneRevisionCharactersMapper.insert(lSceneRevisionCharactersKey); } } // save strands SceneRevisionStrandsMapper lSceneRevisionStrandsMapper = lSqlSession .getMapper(SceneRevisionStrandsMapper.class); SceneRevisionStrandsExample lSceneRevisionStrandsExample = new SceneRevisionStrandsExample(); lSceneRevisionStrandsExample.createCriteria() .andIdSceneRevisionEqualTo((pSceneRevisionDTO.getIdRevision())); lSceneRevisionStrandsMapper.deleteByExample(lSceneRevisionStrandsExample); if (pSceneRevisionDTO.getStrands() != null && pSceneRevisionDTO.getStrands().size() > 0) { for (Integer lIntIdStrand : pSceneRevisionDTO.getStrands()) { SceneRevisionStrandsKey lSceneRevisionStrands = new SceneRevisionStrandsKey(); lSceneRevisionStrands.setIdStrand(lIntIdStrand); lSceneRevisionStrands.setIdSceneRevision(pSceneRevisionDTO.getIdRevision()); lSceneRevisionStrandsMapper.insert(lSceneRevisionStrands); } } lSqlSession.commit(); } catch (Throwable t) { mLog.error(t); lSqlSession.rollback(); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End save(SceneDTO)"); }
From source file:com.bibisco.manager.SceneTagsManager.java
License:GNU General Public License
/** * @return a Map as//from w w w.j av a2 s . c om * * Chapter.1 Chapter.2 Chapter.3 * - character.1 - X X * - character.2 - X * - character.3 - X X * */ public static Map<String, List<Boolean>> getCharactersChaptersPresence() { Map<String, List<Boolean>> lMapCharacterChapterPresence = new HashMap<String, List<Boolean>>(); mLog.debug("Start getCharactersChaptersDistribution()"); List<com.bibisco.bean.CharacterDTO> lListCharacterDTO = CharacterManager.loadAll(); List<ChapterDTO> lListChapters = ChapterManager.loadAll(); if (CollectionUtils.isEmpty(lListCharacterDTO) || CollectionUtils.isEmpty(lListChapters)) { mLog.debug("End getStrandsChaptersDistribution()"); return lMapCharacterChapterPresence; } SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { VSceneTagsMapper lVSceneTagsMapper = lSqlSession.getMapper(VSceneTagsMapper.class); VSceneTagsExample lVSceneTagsExample = new VSceneTagsExample(); lVSceneTagsExample.setOrderByClause("chapter_position, id_character"); List<VSceneTags> lListVSceneTags = lVSceneTagsMapper.selectByExample(lVSceneTagsExample); if (lListVSceneTags != null && lListVSceneTags.size() > 0) { Map<Integer, Set<Integer>> lMapCharactersChaptersDistribution = new HashMap<Integer, Set<Integer>>(); int lIntLastChapter = -1; Set<Integer> lSetChapterCharacters = null; // filter duplicate items using a set for (VSceneTags lVSceneTags : lListVSceneTags) { if (lVSceneTags.getChapterPosition().intValue() != lIntLastChapter) { lSetChapterCharacters = new HashSet<Integer>(); lMapCharactersChaptersDistribution.put(lVSceneTags.getChapterPosition(), lSetChapterCharacters); lIntLastChapter = lVSceneTags.getChapterPosition(); } if (lVSceneTags.getIdCharacter() != null) { lSetChapterCharacters.add(lVSceneTags.getIdCharacter().intValue()); } } // populate result map for (CharacterDTO lCharacterDTO : lListCharacterDTO) { List<Boolean> lListCharacterChapterPresence = new ArrayList<Boolean>(); lMapCharacterChapterPresence.put(lCharacterDTO.getIdCharacter().toString(), lListCharacterChapterPresence); for (ChapterDTO lChapterDTO : lListChapters) { Set<Integer> lSetCharacters = lMapCharactersChaptersDistribution .get(lChapterDTO.getPosition()); if (lSetCharacters != null && !lSetCharacters.isEmpty() && lSetCharacters.contains(lCharacterDTO.getIdCharacter())) { lListCharacterChapterPresence.add(Boolean.TRUE); } else { lListCharacterChapterPresence.add(Boolean.FALSE); } } } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End getCharactersChaptersDistribution()"); return lMapCharacterChapterPresence; }
From source file:com.bibisco.manager.SceneTagsManager.java
License:GNU General Public License
/** ** * @return a Map as/* ww w.j a va2 s . c om*/ * * Chapter.1 Chapter.2 Chapter.3 * - location.1 - X X * - location.2 - X * - location.3 - X X * */ public static Map<String, List<Boolean>> getLocationsChaptersPresence() { Map<String, List<Boolean>> lMapLocationChapterPresence = new HashMap<String, List<Boolean>>(); mLog.debug("Start getLocationsChaptersDistribution()"); List<com.bibisco.bean.LocationDTO> lListLocationDTO = LocationManager.loadAll(); List<ChapterDTO> lListChapters = ChapterManager.loadAll(); if (CollectionUtils.isEmpty(lListLocationDTO) || CollectionUtils.isEmpty(lListChapters)) { mLog.debug("End getStrandsChaptersDistribution()"); return lMapLocationChapterPresence; } SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { VSceneTagsMapper lVSceneTagsMapper = lSqlSession.getMapper(VSceneTagsMapper.class); VSceneTagsExample lVSceneTagsExample = new VSceneTagsExample(); lVSceneTagsExample.setOrderByClause("chapter_position, id_location"); List<VSceneTags> lListVSceneTags = lVSceneTagsMapper.selectByExample(lVSceneTagsExample); if (lListVSceneTags != null && lListVSceneTags.size() > 0) { Map<Integer, Set<Integer>> lMapLocationsChaptersDistribution = new HashMap<Integer, Set<Integer>>(); int lIntLastChapter = -1; Set<Integer> lSetChapterLocations = null; // filter duplicate items using a set for (VSceneTags lVSceneTags : lListVSceneTags) { if (lVSceneTags.getChapterPosition().intValue() != lIntLastChapter) { lSetChapterLocations = new HashSet<Integer>(); lMapLocationsChaptersDistribution.put(lVSceneTags.getChapterPosition(), lSetChapterLocations); lIntLastChapter = lVSceneTags.getChapterPosition(); } if (lVSceneTags.getIdLocation() != null) { lSetChapterLocations.add(lVSceneTags.getIdLocation().intValue()); } } // populate result map for (LocationDTO lLocationDTO : lListLocationDTO) { List<Boolean> lListLocationChapterPresence = new ArrayList<Boolean>(); lMapLocationChapterPresence.put(lLocationDTO.getIdLocation().toString(), lListLocationChapterPresence); for (ChapterDTO lChapterDTO : lListChapters) { Set<Integer> lSetLocations = lMapLocationsChaptersDistribution .get(lChapterDTO.getPosition()); if (lSetLocations != null && !lSetLocations.isEmpty() && lSetLocations.contains(lLocationDTO.getIdLocation())) { lListLocationChapterPresence.add(Boolean.TRUE); } else { lListLocationChapterPresence.add(Boolean.FALSE); } } } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End getLocationsChaptersDistribution()"); return lMapLocationChapterPresence; }
From source file:com.bibisco.manager.SceneTagsManager.java
License:GNU General Public License
/** * @return a Map as/*from ww w . j av a 2 s . com*/ * * Chapter.1 Chapter.2 Chapter.3 * - strand.1 - X X * - strand.2 - X * - strand.3 - X X * */ public static Map<String, List<Boolean>> getStrandsChaptersPresence() { Map<String, List<Boolean>> lMapStrandChapterPresence = new HashMap<String, List<Boolean>>(); mLog.debug("Start getStrandsChaptersDistribution()"); List<com.bibisco.bean.StrandDTO> lListStrandDTO = StrandManager.loadAll(); List<ChapterDTO> lListChapters = ChapterManager.loadAll(); if (CollectionUtils.isEmpty(lListStrandDTO) || CollectionUtils.isEmpty(lListChapters)) { mLog.debug("End getStrandsChaptersDistribution()"); return lMapStrandChapterPresence; } SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { VSceneTagsMapper lVSceneTagsMapper = lSqlSession.getMapper(VSceneTagsMapper.class); VSceneTagsExample lVSceneTagsExample = new VSceneTagsExample(); lVSceneTagsExample.setOrderByClause("chapter_position, id_strand"); List<VSceneTags> lListVSceneTags = lVSceneTagsMapper.selectByExample(lVSceneTagsExample); if (lListVSceneTags != null && lListVSceneTags.size() > 0) { Map<Integer, Set<Integer>> lMapStrandsChaptersDistribution = new HashMap<Integer, Set<Integer>>(); int lIntLastChapter = -1; Set<Integer> lSetChapterStrands = null; // filter duplicate items using a set for (VSceneTags lVSceneTags : lListVSceneTags) { if (lVSceneTags.getChapterPosition().intValue() != lIntLastChapter) { lSetChapterStrands = new HashSet<Integer>(); lMapStrandsChaptersDistribution.put(lVSceneTags.getChapterPosition(), lSetChapterStrands); lIntLastChapter = lVSceneTags.getChapterPosition(); } if (lVSceneTags.getIdStrand() != null) { lSetChapterStrands.add(lVSceneTags.getIdStrand().intValue()); } } // populate result map for (StrandDTO lStrandDTO : lListStrandDTO) { List<Boolean> lListStrandChapterPresence = new ArrayList<Boolean>(); lMapStrandChapterPresence.put(lStrandDTO.getIdStrand().toString(), lListStrandChapterPresence); for (ChapterDTO lChapterDTO : lListChapters) { Set<Integer> lSetStrands = lMapStrandsChaptersDistribution.get(lChapterDTO.getPosition()); if (lSetStrands != null && !lSetStrands.isEmpty() && lSetStrands.contains(lStrandDTO.getIdStrand())) { lListStrandChapterPresence.add(Boolean.TRUE); } else { lListStrandChapterPresence.add(Boolean.FALSE); } } } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End getStrandsChaptersDistribution()"); return lMapStrandChapterPresence; }
From source file:com.bibisco.manager.SceneTagsManager.java
License:GNU General Public License
/** * @return a Map as/* w w w . j ava 2 s.c om*/ * * Chapter.1 Chapter.2 Chapter.3 * - pointOfView.1 - X X * - pointOfView.2 - X * - pointOfView.3 - X X * */ public static Map<String, List<Boolean>> getPointOfViewsChaptersPresence() { Map<String, List<Boolean>> lMapPointOfViewChapterPresence = new HashMap<String, List<Boolean>>(); mLog.debug("Start getPointOfViewsChaptersDistribution()"); List<PointOfView4AnalysisDTO> lListPointOfViewDTO = getPointOfView4AnalysisList(); List<ChapterDTO> lListChapters = ChapterManager.loadAll(); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { VSceneTagsMapper lVSceneTagsMapper = lSqlSession.getMapper(VSceneTagsMapper.class); VSceneTagsExample lVSceneTagsExample = new VSceneTagsExample(); lVSceneTagsExample.setOrderByClause("chapter_position, point_of_view, point_of_view_id_character"); List<VSceneTags> lListVSceneTags = lVSceneTagsMapper.selectByExample(lVSceneTagsExample); if (lListVSceneTags != null && lListVSceneTags.size() > 0) { Map<Integer, Set<String>> lMapPointOfViewsChaptersDistribution = new HashMap<Integer, Set<String>>(); int lIntLastChapter = -1; Set<String> lSetChapterPointOfViews = null; // filter duplicate items using a set for (VSceneTags lVSceneTags : lListVSceneTags) { if (lVSceneTags.getChapterPosition().intValue() != lIntLastChapter) { lSetChapterPointOfViews = new HashSet<String>(); lMapPointOfViewsChaptersDistribution.put(lVSceneTags.getChapterPosition(), lSetChapterPointOfViews); lIntLastChapter = lVSceneTags.getChapterPosition(); } if (lVSceneTags.getPointOfView() != null) { lSetChapterPointOfViews.add(lVSceneTags.getIdPointOfView4Analysis()); } } // populate result map for (PointOfView4AnalysisDTO lPointOfView4AnalysisDTO : lListPointOfViewDTO) { List<Boolean> lListPointOfViewChapterPresence = new ArrayList<Boolean>(); lMapPointOfViewChapterPresence.put(lPointOfView4AnalysisDTO.getIdPointOfView4Analysis(), lListPointOfViewChapterPresence); for (ChapterDTO lChapterDTO : lListChapters) { Set<String> lSetPointOfViews = lMapPointOfViewsChaptersDistribution .get(lChapterDTO.getPosition()); if (lSetPointOfViews != null && !lSetPointOfViews.isEmpty() && lSetPointOfViews .contains(lPointOfView4AnalysisDTO.getIdPointOfView4Analysis())) { lListPointOfViewChapterPresence.add(Boolean.TRUE); } else { lListPointOfViewChapterPresence.add(Boolean.FALSE); } } } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End getPointOfViewsChaptersDistribution()"); return lMapPointOfViewChapterPresence; }
From source file:com.bibisco.manager.SceneTagsManager.java
License:GNU General Public License
public static List<PointOfView4AnalysisDTO> getPointOfView4AnalysisList() { mLog.debug("Start getPointOfView4AnalysisList()"); List<PointOfView4AnalysisDTO> lListPointOfView4AnalysisDTO = new ArrayList<PointOfView4AnalysisDTO>(); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/* w w w. j a v a2 s. c o m*/ VPointOfView4AnalysisExample lVPointOfView4AnalysisExample = new VPointOfView4AnalysisExample(); lVPointOfView4AnalysisExample.setOrderByClause("point_of_view, position"); VPointOfView4AnalysisMapper lVPointOfView4AnalysisMapper = lSqlSession .getMapper(VPointOfView4AnalysisMapper.class); List<VPointOfView4Analysis> lListVPointOfView4Analysis = lVPointOfView4AnalysisMapper .selectByExample(lVPointOfView4AnalysisExample); if (lListVPointOfView4Analysis != null && lListVPointOfView4Analysis.size() > 0) { for (VPointOfView4Analysis lVPointOfView4Analysis : lListVPointOfView4Analysis) { PointOfView4AnalysisDTO lPointOfView4AnalysisDTO = new PointOfView4AnalysisDTO(); lPointOfView4AnalysisDTO .setIdPointOfView4Analysis(lVPointOfView4Analysis.getIdPointOfView4Analysis()); lPointOfView4AnalysisDTO.setCharacterName(lVPointOfView4Analysis.getPointOfViewCharacterName()); lPointOfView4AnalysisDTO.setIdCharacter(lVPointOfView4Analysis.getPointOfViewIdCharacter()); lPointOfView4AnalysisDTO.setPointOfView( PointOfView.getPointOfViewFromValue(lVPointOfView4Analysis.getPointOfView())); lListPointOfView4AnalysisDTO.add(lPointOfView4AnalysisDTO); } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End getPointOfView4AnalysisList()"); return lListPointOfView4AnalysisDTO; }
From source file:com.bibisco.manager.SceneTagsManager.java
License:GNU General Public License
public static Map<Integer, List<CharacterSceneDTO>> getCharacterSceneAnalysis() { Map<Integer, List<CharacterSceneDTO>> lMapCharacterSceneAnalysis = new HashMap<Integer, List<CharacterSceneDTO>>(); mLog.debug("Start getCharacterSceneAnalysis()"); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {// ww w . j a v a 2 s . co m VCharacterSceneExample lVCharacterSceneExample = new VCharacterSceneExample(); lVCharacterSceneExample.setOrderByClause("main_character desc, character_position, scene_date "); VCharacterSceneMapper lVCharacterSceneMapper = lSqlSession.getMapper(VCharacterSceneMapper.class); List<VCharacterScene> lListVCharacterScene = lVCharacterSceneMapper .selectByExample(lVCharacterSceneExample); if (lListVCharacterScene != null && lListVCharacterScene.size() > 0) { int lIntLastCharacter = -1; List<CharacterSceneDTO> lListCharacterSceneDTO = null; for (VCharacterScene lVCharacterScene : lListVCharacterScene) { if (lVCharacterScene.getIdCharacter().intValue() != lIntLastCharacter) { lListCharacterSceneDTO = new ArrayList<CharacterSceneDTO>(); lMapCharacterSceneAnalysis.put(lVCharacterScene.getIdCharacter().intValue(), lListCharacterSceneDTO); lIntLastCharacter = lVCharacterScene.getIdCharacter().intValue(); } CharacterSceneDTO lCharacterSceneDTO = new CharacterSceneDTO(); lCharacterSceneDTO.setIdCharacter(lVCharacterScene.getIdCharacter().intValue()); lCharacterSceneDTO.setCharacterName(lVCharacterScene.getCharacterName()); lCharacterSceneDTO.setIdChapter(lVCharacterScene.getIdChapter().intValue()); lCharacterSceneDTO.setChapterPosition(lVCharacterScene.getChapterPosition()); lCharacterSceneDTO.setChapterTitle(lVCharacterScene.getChapterTitle()); lCharacterSceneDTO.setIdScene(lVCharacterScene.getIdScene().intValue()); lCharacterSceneDTO.setSceneDate(lVCharacterScene.getSceneDate()); lCharacterSceneDTO.setSceneDescription(lVCharacterScene.getSceneDescription()); if (lVCharacterScene.getIdLocation() != null) { lCharacterSceneDTO.setIdLocation(lVCharacterScene.getIdLocation().intValue()); } lCharacterSceneDTO.setLocationNation(lVCharacterScene.getLocationNation()); lCharacterSceneDTO.setLocationState(lVCharacterScene.getLocationState()); lCharacterSceneDTO.setLocationCity(lVCharacterScene.getLocationCity()); lCharacterSceneDTO.setLocationName(lVCharacterScene.getLocationName()); lListCharacterSceneDTO.add(lCharacterSceneDTO); } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End getCharacterSceneAnalysis()"); return lMapCharacterSceneAnalysis; }
From source file:com.bibisco.manager.StrandManager.java
License:GNU General Public License
public static List<StrandDTO> loadAll() { List<StrandDTO> lListStrandDTO = null; mLog.debug("Start loadAll()"); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryProject(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/* w w w.j av a 2 s . c om*/ StrandsMapper lStrandsMapper = lSqlSession.getMapper(StrandsMapper.class); StrandsExample lStrandsExample = new StrandsExample(); lStrandsExample.setOrderByClause("position"); List<Strands> lListStrands = lStrandsMapper.selectByExampleWithBLOBs(lStrandsExample); if (lListStrands != null && lListStrands.size() > 0) { lListStrandDTO = new ArrayList<StrandDTO>(); for (Strands lStrands : lListStrands) { lListStrandDTO.add(createStrandDTOFromStrands(lStrands)); } } } catch (Throwable t) { mLog.error(t); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End loadAll()"); return lListStrandDTO; }