List of usage examples for org.apache.ibatis.session SqlSession rollback
void rollback();
From source file:net.cbtltd.server.PartyService.java
/** * Executes the AgentNameIdAction action to read a list of agent NameId instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.//from w w w .java 2 s .c om */ public final Table<NameId> execute(SqlSession sqlSession, AgentNameIdAction action) { LOG.debug("NameIdAction " + action); Table<NameId> table = new Table<NameId>(); try { if (action.isSuggested()) { table.setValue(sqlSession.getMapper(PartyMapper.class).nameidbyid(action)); } else { ArrayList<String> agentRoles = new ArrayList<String>(); agentRoles.add(String.valueOf(AccessControl.AGENCY)); agentRoles.add(String.valueOf(AccessControl.AGENT)); action.setIds(agentRoles); table.setValue(sqlSession.getMapper(PartyMapper.class).agentnameidbyname(action)); } } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } LOG.debug("NameIdAction " + table); return table; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the PartyCreatorList action to read a list of affiliate NameId instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response.//from w ww .j a va 2 s . com */ public final Table<NameId> execute(SqlSession sqlSession, PartyCreatorList action) { Table<NameId> table = new Table<NameId>(); try { table.setValue(sqlSession.getMapper(PartyMapper.class).creatornameid(action.getEmailaddress())); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return table; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the PartySessionTable action to read a list of session instances for a user. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w w w . j av a2 s . c om*/ */ public final Table<Session> execute(SqlSession sqlSession, PartySessionTable action) { Table<Session> table = new Table<Session>(); try { table.setDatasize(sqlSession.getMapper(PartyMapper.class).actorsessioncount(action)); table.setValue(sqlSession.getMapper(PartyMapper.class).actorsessionlist(action)); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return table; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the AgentCreate action to create an agency (Party of type agent) instance. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w w w.ja v a2s. c om*/ */ public final Organization execute(SqlSession sqlSession, AgentCreate action) { try { Party exists = sqlSession.getMapper(PartyMapper.class).readbyemailaddress(action.getEmailaddress()); if (exists == null) { sqlSession.getMapper(PartyMapper.class).create(action); } action.setCurrency(Currency.Code.USD.name()); action.setLanguage(Language.EN); RelationService.create(sqlSession, Relation.PARTY_ROLE, action.getId(), String.valueOf(AccessControl.AGENCY)); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Actor.name(), action.getId(), action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Employer.name(), action.getId(), action.getId()); ArrayList<String> organizationids = RelationService.read(sqlSession, Relation.ORG_PARTY_ + Party.Type.Organization.name(), null, null); organizationids.add(action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Agent.name(), organizationids, action.getId()); if (action.hasOldstate(Party.INITIAL)) { EmailService.partyCreate(action); } MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Party, action); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return action; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the OrganizationCreate action to create a property manager (Party of type organization) instance. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the organization/*from w ww .j ava2 s . c o m*/ */ public final Organization execute(SqlSession sqlSession, OrganizationCreate action) { LOG.debug("OrganizationCreate in " + action); try { Party exists = sqlSession.getMapper(PartyMapper.class).readbyemailaddress(action.getEmailaddress()); if (exists == null) { sqlSession.getMapper(PartyMapper.class).create(action); } action.setEmployerid(action.getId()); action.setCurrency(Currency.Code.USD.name()); action.setLanguage(Language.EN); sqlSession.getMapper(PartyMapper.class).insertlogo(action.getId()); sqlSession.getMapper(PartyMapper.class).insertaccounts(action.getId()); RelationService.create(sqlSession, Relation.PARTY_ROLE, action.getId(), String.valueOf(AccessControl.ADMINISTRATOR)); RelationService.replace(sqlSession, Relation.PARTY_VALUE, action.getId(), action.getValues()); RelationService.create(sqlSession, Relation.ORGANIZATION_CURRENCY, action.getId(), Currency.Code.USD.name()); RelationService.create(sqlSession, Relation.ORGANIZATION_LANGUAGE, action.getId(), Language.EN); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Actor.name(), action.getId(), action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Employer.name(), action.getId(), action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Organization.name(), action.getId(), action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Owner.name(), action.getId(), action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Supplier.name(), action.getId(), action.getId()); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Supplier.name(), action.getId(), Party.CBT_LTD_PARTY); //Licensor RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Actor.name(), action.getId(), Party.NO_ACTOR); ArrayList<String> organizationids = RelationService.read(sqlSession, Relation.ORG_PARTY_ + Party.Type.Organization.name(), null, null); RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Organization.name(), action.getId(), organizationids); //allow partner APIS to be scheduled into a single Parnter API. RelationService.create(sqlSession, Relation.ORG_PARTY_ + Party.Type.Organization.name(), organizationids, action.getId()); sqlSession.getMapper(PartyMapper.class).update(action); sqlSession.commit(); final NameIdAction param = new NameIdAction(); param.setOrganizationid(action.getId()); action.setCurrencies( RelationService.read(sqlSession, Relation.ORGANIZATION_CURRENCY, action.getId(), null)); action.setLanguages( RelationService.read(sqlSession, Relation.ORGANIZATION_LANGUAGE, action.getId(), null)); action.setCurrency(Currency.Code.USD.name()); action.setLanguage(Language.EN); MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Party, action); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } LOG.debug("OrganizationCreate out " + action); return action; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the OrganizationUpdate action to update a property manager instance. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the organization/*w w w . ja v a2 s . c o m*/ */ public static final Organization execute(SqlSession sqlSession, OrganizationUpdate action) { //LOG.debug("OrganizationUpdate " + action); try { if (action.hasPassword()) { String password = Party.decrypt(action.getPassword()); action.setPassword(BCrypt.hashpw(password, BCrypt.gensalt())); } else { action.setPassword(null); } sqlSession.getMapper(PartyMapper.class).update(action); RelationService.replace(sqlSession, Relation.PARTY_VALUE, action.getId(), action.getValues()); RelationService.replace(sqlSession, Relation.ORGANIZATION_CURRENCY, action.getId(), action.getCurrencies()); RelationService.replace(sqlSession, Relation.ORGANIZATION_LANGUAGE, action.getId(), action.getLanguages()); TextService.update(sqlSession, action.getTexts()); WorkflowService.update(sqlSession, action.getWorkflows()); if (action.hasOldstate(Party.INITIAL) && action.getNeedToSendEmail()) { EmailService.partyCreate(action); } MonitorService.update(sqlSession, Data.Origin.CONSOLE, NameId.Type.Party, action); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return action; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the PartyRelationTable action to read a list of role instances for a user. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*w ww . j a v a2 s . c o m*/ */ public final Table<Party> execute(SqlSession sqlSession, PartyRelationTable action) { Table<Party> table = new Table<Party>(); try { table.setDatasize(sqlSession.getMapper(PartyMapper.class).relationcount(action)); table.setValue(sqlSession.getMapper(PartyMapper.class).relationlist(action)); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return table; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the RolePartyTable action to read a list of role instances for a user. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w w w .j a v a2s . c o m*/ */ public final Table<Party> execute(SqlSession sqlSession, RolePartyTable action) { Table<Party> table = new Table<Party>(); try { table.setDatasize(sqlSession.getMapper(PartyMapper.class).partyrolecount(action)); table.setValue(sqlSession.getMapper(PartyMapper.class).partyrolelist(action)); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return table; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the WorkflowNameId action to read a list of work flow NameId instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w w w . j a va2s . co m*/ */ public final Table<NameId> execute(SqlSession sqlSession, WorkflowNameId action) { Table<NameId> table = new Table<NameId>(); try { table.setValue(sqlSession.getMapper(PartyMapper.class).workflownameid(action)); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return table; }
From source file:net.cbtltd.server.PartyService.java
/** * Executes the NameIdType action to read a list of account type NameId instances. * * @param sqlSession the current SQL session. * @param action the action to be executed. * @return the response./*from w w w. ja v a 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(PartyMapper.class).type(action)); } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); } return table; }