コード例 #1
0
 /**
  * Creating all new Applies received as an argument
  *
  * @param app value of Applies
  */
 public void createApply(ArrayList<Apply> app) {
   sessionFactory = HibernateUtil.configureSessionFactory();
   session = sessionFactory.openSession();
   tx = session.beginTransaction();
   for (Apply a : app) session.persist(a);
   tx.commit();
   session.close();
 }
コード例 #2
0
  /**
   * Creating a new environment
   *
   * @param env value of the environment
   */
  public void createEnvironment(Environment env) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    session.persist(env);
    tx.commit();
    session.close();
  }
コード例 #3
0
  /**
   * Creating all new Expressions send as an argument
   *
   * @param exp value of Expressions
   */
  public void createExpression(ArrayList<Expression> exp) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    for (Expression e : exp) session.persist(e);
    tx.commit();
    session.close();
  }
コード例 #4
0
  /**
   * Creating a new Condition
   *
   * @param cond value of Condition
   */
  public void createCondition(Condition cond) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    session.persist(cond);
    tx.commit();
    session.close();
  }
コード例 #5
0
  /**
   * Creating a new environment
   *
   * @param description description of the environment
   * @param environment value of the environment
   */
  public void createEnvironment(String description, String environment) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    Environment env = new Environment(environment, description);
    session.persist(env);
    tx.commit();
    session.close();
  }
コード例 #6
0
  /**
   * Fetching list of environment elements from database
   *
   * @return list of environment elements
   */
  @SuppressWarnings("unchecked")
  public List<Environment> selectEnvironment() {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();
    query = session.createQuery("from Environment");
    List<Environment> env = query.list();

    tx.commit();
    session.close();
    return env;
  }
コード例 #7
0
  /**
   * Deleting an environment
   *
   * @param pkEnvironment primary key of the environment
   */
  public void deleteEnvironment(Long pkEnvironment) {

    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    query = session.createQuery("from Environment e where e.pkEnvironment = " + pkEnvironment);
    Environment env = (Environment) query.uniqueResult();

    session.delete(env);
    tx.commit();
    session.close();
  }
コード例 #8
0
  public List<Resource> getResource() {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    Query query = session.createQuery("from Resource");
    @SuppressWarnings("unchecked")
    List<Resource> res = query.list();

    tx.commit();
    session.close();
    return res;
  }
コード例 #9
0
  public List<Action> getAction() {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    Query query = session.createQuery("from Action");
    @SuppressWarnings("unchecked")
    List<Action> act = query.list();

    tx.commit();
    session.close();
    return act;
  }
コード例 #10
0
  public List<Subject> getSubject() {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    Query query = session.createQuery("from Subject");
    @SuppressWarnings("unchecked")
    List<Subject> subj = query.list();

    tx.commit();
    session.close();
    return subj;
  }
コード例 #11
0
  /**
   * Deleting a Condition
   *
   * @param cond value of condition
   */
  public void deleteCondition(Condition cond) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    Expression testApply = cond.getExpression();

    session.delete(testApply);
    // session.delete(cond);

    tx.commit();
    session.close();
  }
コード例 #12
0
  /**
   * Updating an environment
   *
   * @param pkEenvironment primary key of the environment
   * @param description description of the environment
   * @param environment value of the environment
   */
  public void updateEnvironment(Long pkEnvironment, String description, String environment) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    query = session.createQuery("from Environment e where e.pkEnvironment =" + pkEnvironment);
    Environment env = (Environment) query.uniqueResult();
    env.setDescription(description);
    env.setEnvironmentName(environment);

    session.persist(env);
    tx.commit();
    session.close();
  }
コード例 #13
0
  /**
   * Creating a new environment
   *
   * @param description description of the environment
   * @param environment value of the environment
   * @param envAttr list of environment attributes
   */
  public void createEnvironment(
      String description, String environment, List<EnvironmentAttribute> envAttr) {
    sessionFactory = HibernateUtil.configureSessionFactory();
    session = sessionFactory.openSession();
    tx = session.beginTransaction();

    Environment env = new Environment(environment, description);

    env.setEnvironmentAttributes(new HashSet<EnvironmentAttribute>(envAttr));
    session.persist(env);

    for (EnvironmentAttribute attr : envAttr) {
      attr.setEnvironment(env);
      session.persist(attr);

      for (EnvAttrValues val : attr.getEnvAttrValues()) {
        val.setEnvironmentAttribute(attr);
        session.persist(val);
      }
    }
    tx.commit();
    session.close();
  }