Package ch.tatool.app.data

Examples of ch.tatool.app.data.ModuleImpl


  /**
   * Save a session without finishing it.
   */
  public void saveSession(final ModuleSession moduleSession) {
    final ModuleImpl moduleImpl = (ModuleImpl) moduleSession.getModule();
    moduleImpl.getTransactionTemplate().execute(
        new TransactionCallbackWithoutResult() {
          public void doInTransactionWithoutResult(TransactionStatus status) {
            moduleImpl.getSessionDAO().saveSession(moduleImpl, moduleSession);
          }
        });
  }
View Full Code Here


        });
  }

  /** Finishes a module session. */
  public void finishSession(final ModuleSession moduleSession) {
    final ModuleImpl moduleImpl = (ModuleImpl) moduleSession.getModule();
    moduleImpl.getTransactionTemplate().execute(
        new TransactionCallbackWithoutResult() {
          public void doInTransactionWithoutResult(TransactionStatus status) {
            moduleSession.setEndTime(new Date());
            moduleImpl.getSessionDAO().saveSession(moduleImpl, moduleSession);
          }
        });
  }
View Full Code Here

  /**
   * Load all session in a given module.
   */
  @SuppressWarnings("unchecked")
  public List<ModuleSession> getSessions(Module module) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (List<ModuleSession>) moduleImpl.getTransactionTemplate()
        .execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getSessionDAO().getSessions(moduleImpl);
          }
        });
  }
View Full Code Here

  // Trial data

  /** Inserts a trial object into the session. */
  public void insertTrial(final ModuleSession session, final Trial trial) {
    final ModuleImpl moduleImpl = (ModuleImpl) session.getModule();
    moduleImpl.getTransactionTemplate().execute(
        new TransactionCallbackWithoutResult() {
          public void doInTransactionWithoutResult(TransactionStatus status) {
            moduleImpl.getTrialDAO().saveTrial(moduleImpl, session, trial);
          }
        });
  }
View Full Code Here

        });
  }

  @SuppressWarnings("unchecked")
  public List<Trial> getTrials(final ModuleSession session) {
    final ModuleImpl moduleImpl = (ModuleImpl) session.getModule();
    return (List<Trial>) moduleImpl.getTransactionTemplate()
        .execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getTrialDAO().getTrials(session);
          }
        });
  }
View Full Code Here

        });
  }

  /** Load all trials of a given module and session. */
  public List<Trial> loadAllTrials(Module module) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (List<Trial>) moduleImpl.getTransactionTemplate()
        .execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getTrialDAO().loadAllTrials(moduleImpl);
          }
        });
  }
View Full Code Here

   * Returns a list of trial instances for a given element or session.
   *
   * @return list of trials
   */
  public List<Trial> getTrials(Module module, final ModuleSession session, final Node node, final int maxResults) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (List<Trial>) moduleImpl.getTransactionTemplate()
        .execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getTrialDAO().getTrials(session, node, maxResults);
          }
        });
  }
View Full Code Here

   *            whether to include unfinished module (modules without end
   *            time)
   * @return the last created session
   */
  public ModuleSession getLastSession(Module module, final boolean includeUnfinished) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (ModuleSession) moduleImpl.getTransactionTemplate()
        .execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getSessionDAO().findLastSession(moduleImpl, includeUnfinished);
          }
        });
  }
View Full Code Here

     */
    public Module createModule(UserAccount account, Map<String, String> moduleProperties, Map<String, byte[]> binaryModuleProperties, Map<String, DataExporter> moduleExporters) {
        final UserAccountImpl accountImpl = (UserAccountImpl) account;
       
        // add the properties and save the object
        final ModuleImpl module = new ModuleImpl();
        module.setAccount(accountImpl);
        module.setAccountId(accountImpl.getId());
        if (moduleProperties != null) {
          module.setModuleProperties(moduleProperties);
        }
      if (binaryModuleProperties != null) {
        module.setBinaryModuleProperties(binaryModuleProperties);
      }
      if (moduleExporters != null) {
        module.setModuleExporters(moduleExporters);
      }
       
        // set the module name
      String moduleName = moduleProperties.get(Module.PROPERTY_MODULE_NAME);
      if (moduleName == null) {
        logger.warn("No module name defined.");
          moduleName = "Module " + System.currentTimeMillis();
          module.getModuleProperties().put(Module.PROPERTY_MODULE_NAME, moduleName);       
      }
      module.setName(moduleName);
       
        // save the module
        accountImpl.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
View Full Code Here

     */
  public Module loadModule(Module.Info info) {
        final ModuleInfoImpl moduleInfoImpl = (ModuleInfoImpl) info;
       
        // load the module from the database
        ModuleImpl module = (ModuleImpl) moduleInfoImpl.getAccount().getTransactionTemplate().execute(
            new TransactionCallback<Object>() {
                public Object doInTransaction(TransactionStatus status) {
                    ModuleDAO moduleDAO = moduleInfoImpl.getAccount().getModuleDAO();
                    ModuleImpl module = moduleDAO.loadModule(moduleInfoImpl);
                    return module;
                }
            }
        );
       
        initializeModule(module);
       
        // initialize exporters for module
        // TODO: String "SpringXmlElementConfig" is defined in ch.tatool.core.module.initializer.SpringExecutorInitializer
        Map<String, DataExporter> exporters = getModuleExportersFromXML(module.getBinaryModuleProperty("SpringXmlElementConfig"));
        module.setModuleExporters(exporters);
       
        return module;
    }
View Full Code Here

TOP

Related Classes of ch.tatool.app.data.ModuleImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.