List of usage examples for org.hibernate Session persist
void persist(Object object);
From source file:edu.harvard.i2b2.crc.dao.setfinder.QueryInstanceDao.java
License:Open Source License
/** * Function to create query instance// ww w . j a va2 s . c o m * @param queryMasterId * @param userId * @param groupId * @param batchMode * @param statusId * @return query instance id */ public String createQueryInstance(String queryMasterId, String userId, String groupId, String batchMode, int statusId) { QtQueryInstance queryInstance = new QtQueryInstance(); queryInstance.setUserId(userId); queryInstance.setGroupId(groupId); queryInstance.setBatchMode(batchMode); queryInstance.setDeleteFlag("N"); QtQueryMaster queryMaster = new QtQueryMaster(); queryMaster.setQueryMasterId(queryMasterId); queryInstance.setQtQueryMaster(queryMaster); QtQueryStatusType statusType = new QtQueryStatusType(); statusType.setStatusTypeId(statusId); Date startDate = Calendar.getInstance().getTime(); queryInstance.setStartDate(startDate); Session session = getSession(); queryInstance.setQtQueryStatusType(statusType); session.persist(queryInstance); return queryInstance.getQueryInstanceId(); }
From source file:edu.mum.computersecurity.reposatory.impl.RoleDaoImpl.java
@Override public void addRole(Role r) { Session session = this.sessionFactory.getCurrentSession(); session.persist(r); }
From source file:edu.mum.computersecurity.reposatory.impl.UserDaoImpl.java
@Override public void addUser(User u) { Session session = this.sessionFactory.getCurrentSession(); session.persist(u); }
From source file:edu.mum.computersecurity.reposatory.impl.UserRolesDaoImpl.java
@Override public void addUserRole(UserRoles ur) { Session session = this.sessionFactory.getCurrentSession(); session.persist(ur); }
From source file:edu.wustl.cab2b.server.queryengine.QueryOperations.java
License:BSD License
public Cab2bQuery addServiceGroupsToQuery(Long queryId, Collection<ServiceGroup> groups) { Session session = HibernateUtil.newSession(); HibernateDatabaseOperations<ServiceGroup> dbopr = new HibernateDatabaseOperations<ServiceGroup>(session); Cab2bQuery query = (Cab2bQuery) session.get(Cab2bQuery.class, queryId); for (ServiceGroup group : groups) { group.setQuery(query);/*from w w w .j a v a 2 s. com*/ session.persist(group); } query = (Cab2bQuery) session.get(Cab2bQuery.class, queryId); query.getServiceGroups(); session.close(); return query; }
From source file:es.urjc.mctwp.service.commands.researchCmds.AttachFile.java
License:Open Source License
@Override public Command runCommand() { Session sesion = factory.getCurrentSession(); file.setFile(Hibernate.createBlob(stream, file.getSize(), sesion)); sesion.persist(file); createLogComment("audit.addFileProtocolable", file.getName(), null, null); return this; }
From source file:es.uvigo.ei.sing.gc.view.initiators.LoginConfirmationInitiator.java
License:Open Source License
@Override public void doInit(Page page, Map<String, Object> args) throws Exception { final String code = Executions.getCurrent().getParameter("code"); final String email = Executions.getCurrent().getParameter("email"); if (code == null || email == null) { Messagebox.show("Missing or invalid login code", "Error", Messagebox.OK, Messagebox.ERROR, new EventListener<Event>() { @Override/* w ww. j av a2 s.c o m*/ public void onEvent(Event event) throws Exception { Executions.sendRedirect("/index.zul"); } }); } else { final Session session = HibernateUtil.currentSession(); final SingUpConfirmation confirmation = ZKUtils.hGet(SingUpConfirmation.class, (String) email, session); if (confirmation == null || !confirmation.getVerificationCode().equals(code)) { Messagebox.show("Missing or invalid login code", "Error", Messagebox.OK, Messagebox.ERROR, new EventListener<Event>() { @Override public void onEvent(Event event) throws Exception { Executions.sendRedirect("/index.zul"); } }); } else { session.delete(confirmation); final User user = new User(confirmation.getEmail(), confirmation.getPassword(), false); session.persist(user); Sessions.getCurrent(true).setAttribute("user", user); Executions.sendRedirect("/home.zul"); } } }
From source file:es.uvigo.ei.sing.gc.view.models.committee.classifiers.ClassifiersViewModel.java
License:Open Source License
@Init @Override//from ww w .ja va 2 s .co m public void init() { super.init(); final Committee committee = this.getCommittee(false); // Refreshed in init if (!committee.hasEvaluator()) { final Session session = HibernateUtil.currentSession(); final Map<String, String> parameters = new HashMap<String, String>(); parameters.put("stratified", "true"); parameters.put("replicationMode", "VIEW"); parameters.put("k", "5"); final ExpertsEvaluatorMetaData evaluator = new ExpertsEvaluatorMetaData(EvaluationStrategy.XValidation, parameters); session.persist(evaluator); for (ClassifierTypes classifier : ClassifierTypes.values()) { try { final ClassifierBuilderMetaData cbmd = new ClassifierBuilderMetaData(classifier.toString(), classifier.getBuilder()); session.persist(cbmd); committee.getClassifiers().add(cbmd); } catch (Exception e) { e.printStackTrace(); } } session.flush(); committee.setEvaluator(evaluator); session.persist(committee); session.flush(); } this.currentClassifierType = ClassifierTypes.IBk; this.nameValidator = new AbstractValidator() { @Override public void validate(ValidationContext ctx) { final String name = (String) ctx.getProperty().getValue(); final Committee committee = ClassifiersViewModel.this.getCommittee(); for (ClassifierBuilderMetaData cbMetaData : committee.getClassifiers()) { if (cbMetaData.getName().equals(name)) { this.addInvalidMessage(ctx, "name", "Classifier names can not be repeated"); } } } }; StatusViewModel.changeInitialStatus("Select the base classifiers and an evaluation method"); }
From source file:es.uvigo.ei.sing.gc.view.models.committee.classifiers.ClassifiersViewModel.java
License:Open Source License
@Command("addClassifier") public void addClassifier() { final ClassifierTypes classifierType = this.getCurrentClassifierType(); this.dataLostNotification("Add Classifier", "Adding a new classifier will provoke data deletion. Do you wish to continue?", CommitteeStatus.EXPERIMENT_EXECUTION, CommitteeStatus.EVALUATOR, new Runnable() { @Override//from www . j a va 2 s . co m public void run() { try { final Committee committee = ClassifiersViewModel.this.getCommittee(); final Set<String> names = new HashSet<String>(); for (ClassifierBuilderMetaData cbMetaData : committee.getClassifiers()) { names.add(cbMetaData.getName()); } String name = classifierType.toString(); int i = 1; while (names.contains(name)) { name = classifierType.toString() + " [" + i++ + "]"; } final ClassifierBuilderMetaData classifierBuilder = new ClassifierBuilderMetaData(name, classifierType.getBuilder()); final Session session = HibernateUtil.currentSession(); session.persist(classifierBuilder); session.flush(); committee.getClassifiers().add(classifierBuilder); session.update(committee); BindUtils.postNotifyChange(null, null, ClassifiersViewModel.this, "classifiers"); ClassifiersViewModel.this.updateExecutions(); } catch (Exception e) { e.printStackTrace(); Messagebox.show("Error creating new classifier", "Error", Messagebox.OK, Messagebox.ERROR); } } }); }
From source file:es.uvigo.ei.sing.gc.view.models.committee.CommitteeViewModel.java
License:Open Source License
@Init public void init() { super.init(); final User user = UserViewModel.getUser(); if (user.getActiveCommittee() == null) { final Committee newCommittee = new Committee(); user.addCommittee(newCommittee); final Session session = HibernateUtil.currentSession(); session.persist(newCommittee); session.flush();/* w ww.j a va 2 s .com*/ } this.committee = user.getActiveCommittee(); this.committeeId = this.committee.getId(); }