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

     */
    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() {
                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
     */
    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());
                    moduleImpl.getSessionDAO().saveSession(moduleImpl, moduleSession);
                    return moduleSession;
                }
            }
        );
        return moduleSession;
View Full Code Here

   
    /**
     * 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

   
    // 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

     * @param module the module to check
     * @param includeUnfinished whether to include unfinished module (modules without end time)
     * @return
     */
    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

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.