Package ch.tatool.app.data

Examples of ch.tatool.app.data.ModuleImpl


     * If no module with given id exists in the database, a new one is created
     *
     * @param moduleInfo the module to load
     */
    public ModuleImpl loadModule(ModuleInfoImpl moduleInfo) {
        ModuleImpl module = (ModuleImpl) getHibernateTemplate().get(ModuleImpl.class, moduleInfo.getId());

        // set the account object manually
        if (! moduleInfo.getAccount().getId().equals(module.getAccountId())) {
            throw new RuntimeException("ModuleInfo and Module object don't belong to each other! Account id mismatch");
        }
        module.setAccount(moduleInfo.getAccount());
       
        return module;
    }
View Full Code Here


                    query.setLong("moduleId", moduleInfo.getId());
                    query.executeUpdate();
                    */
                 
                  // and finally the module itself
                  ModuleImpl module = loadModule(moduleInfo);
                    session.delete(module);
                    return null;
                }
            }
        );
View Full Code Here

   *            time)
   * @return
   */
  @SuppressWarnings("unchecked")
  public long getSessionCount(Module module, final boolean includeUnfinished) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (Long) moduleImpl.getTransactionTemplate().execute(
        new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getSessionDAO().getSessionCount(moduleImpl, includeUnfinished);
          }
        });
  }
View Full Code Here

   * Find the last x trials with given property of a given element
   *
   */
  @SuppressWarnings("unchecked")
  public List<Trial> getTrials(final Module module, final ModuleSession session, final String elementNameLike, final String propertyNameLike, final int offset, 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(moduleImpl, session, elementNameLike, propertyNameLike, offset, maxResults);
          }
        });
  }
View Full Code Here

   * @return a List of object arrays containing [0] the item name and [1] the
   *         property name
   */
  @SuppressWarnings("unchecked")
  public List<Object[]> findDistinctTrialPropertyNames(final Module module) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (List<Object[]>) moduleImpl.getTransactionTemplate().execute(
        new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getTrialDAO().findDistinctTrialPropertyNames(moduleImpl);
          }
        });
  }
View Full Code Here

   * @return a List of object arrays containing [0] the item name and [1] the
   *         property name
   */
  @SuppressWarnings("unchecked")
  public List<Object[]> findDistinctSessionPropertyNames(final Module module) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    return (List<Object[]>) moduleImpl.getTransactionTemplate().execute(
        new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            return moduleImpl.getSessionDAO().findDistinctSessionPropertyNames(moduleImpl);
          }
        });
  }
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

  /**
   * Save the module instance. This will save all changed module properties
   */
  public void saveModule(Module module) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    // load the module data
    moduleImpl.getTransactionTemplate().execute(
        new TransactionCallbackWithoutResult() {
          public void doInTransactionWithoutResult(TransactionStatus status) {
            ModuleDAO moduleDAO = moduleImpl.getModuleDAO();
            moduleDAO.saveModule(moduleImpl);
          }
        });
  }
View Full Code Here

  /**
   * Creates a new module session. The module start date is set immediately
   */
  @SuppressWarnings("unchecked")
  public ModuleSession createSession(Module module) {
    final ModuleImpl moduleImpl = (ModuleImpl) module;
    ModuleSession moduleSession = (ModuleSession) moduleImpl
        .getTransactionTemplate().execute(new TransactionCallback() {
          public Object doInTransaction(TransactionStatus status) {
            ModuleSession moduleSession = new ModuleSessionImpl();
            moduleSession.setStartTime(new Date());
            moduleSession.setCompleted(0);
            moduleImpl.getSessionDAO().saveSession(moduleImpl, moduleSession);
            return moduleSession;
          }
        });
    return moduleSession;
  }
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.