Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.PersistentFactory


   */
  @Override
  public void loadPersistents(ModelRequest request, FormularDescriptor formular, PersistentDescriptor persistents,
          List<Configuration> persistentConfig, Integer id) throws ModelException, PersistenceException
  {
    PersistentFactory persistentManager = (PersistentFactory) request.getService(PersistentFactory.ROLE, request
            .getDomain());

    try
    {
      if (persistentConfig.size() > 0)
      {
        Iterator persistentConfigIterator = persistentConfig.iterator();
        Configuration aPersistentConfig = (Configuration) persistentConfigIterator.next();

        if (aPersistentConfig.getAttribute("name", null) != null)
        {
          Persistent persistent = persistentManager.create(aPersistentConfig.getAttribute("name"));

          if (id.intValue() != - 1)
          {
            persistent.setField(aPersistentConfig.getAttribute("key"), id);
            persistent.find();
          }

          persistents.put(aPersistentConfig.getAttribute("id"), persistent);

          for (; persistentConfigIterator.hasNext();)
          {
            aPersistentConfig = (Configuration) persistentConfigIterator.next();

            if (aPersistentConfig.getAttribute("join", null) != null)
            {
              persistent = persistentManager.create(aPersistentConfig.getAttribute("name"));
              persistents.put(aPersistentConfig.getAttribute("id"), persistent);

              if (id.intValue() != - 1)
              {
                persistent.setField(aPersistentConfig.getAttribute("myKey"), persistents.getPersistent(
View Full Code Here


   * for another user
   */
  protected String getActualUserName(ModelRequest request)
    throws PersistenceException, PermissionException, ModelException
  {
    PersistentFactory pf = (PersistentFactory) request.getService(PersistentFactory.ROLE, request.getDomain());

    String userName = UserTools.getCurrentUserName(request);

    if (! StringTools.isTrimEmpty(request.getParameter("userId")))
    {
      int userId = request.getParameterAsInt("userId", - 1);

      if (! UserTools.currentUserIsInGroup(request, "manager") && UserTools.getCurrentUserId(request) != userId)
      {
        throw new PermissionException("Permission denied to edit com device function keys of user " + userId);
      }

      try
      {
        Persistent user = pf.create("keel.user");

        user.setField("uid", userId);
        user.find();
        userName = user.getFieldString("name");
      }
View Full Code Here

        {
          request.getParameter(keyName).toString()
        };
      }

      PersistentFactory persistentManager = (PersistentFactory) wrappedRequest.getService(PersistentFactory.ROLE,
              wrappedRequest.getDomain());

      for (int i = 0; i < ids.length; ++i)
      {
        Persistent persistent = null;
        Object bean = null;

        if (persistentConfig.size() != 0)
        {
          if (persistentConfig.get(0).getAttribute("name", null) != null)
          {
            persistent = persistentManager.create(persistentConfig.get(0).getAttribute("name"));
            persistent.setField(persistentConfig.get(0).getAttribute("key"), NumberTools.toIntInstance(
                    ids[i], - 1));
            persistent.find();
          }
          else
View Full Code Here

   * for another user
   */
  protected String getActualUserName(ModelRequest request)
    throws PersistenceException, PermissionException, ModelException
  {
    PersistentFactory pf = (PersistentFactory) request.getService(PersistentFactory.ROLE, request.getDomain());

    String userName = UserTools.getCurrentUserName(request);

    if (request.getParameter("userId") != null)
    {
      int userId = NumberTools.toInt(request.getParameter("userId"), UserTools.getCurrentUserId(request));

      if (! UserTools.currentUserIsInGroup(request, "manager") && UserTools.getCurrentUserId(request) != userId)
      {
        throw new PermissionException("Permission denied to edit com device function keys of user " + userId);
      }

      try
      {
        Persistent user = pf.create("keel.user");

        user.setField("uid", userId);
        user.find();
        userName = user.getFieldString("name");
      }
View Full Code Here

      listing.setItemCommands(cmdDescriptor);
    }

    PersistentDescriptor persistents = new PersistentDescriptor();
    PersistentFactory persistentManager = null;

    try
    {
      persistentManager = (PersistentFactory) KeelTools.getService(PersistentFactory.ROLE);

      if (persistentConfig.size() > 0)
      {
        Iterator persistentConfigIterator = persistentConfig.iterator();
        Configuration aPersistentConfig = (Configuration) persistentConfigIterator.next();

        Persistent persistent = persistentManager.create(aPersistentConfig.getAttribute("name"));

        persistents.put(aPersistentConfig.getAttribute("id"), persistent);

        for (; persistentConfigIterator.hasNext();)
        {
          aPersistentConfig = (Configuration) persistentConfigIterator.next();

          persistent = persistentManager.create(aPersistentConfig.getAttribute("name"));

          String join = aPersistentConfig.getAttribute("join", null);

          if (join != null)
          {
View Full Code Here

    return true;
  }

  protected Persistent getUserPersistent() throws UserMgrException
  {
    PersistentFactory pf = null;
    Persistent myUser = null;

    try
    {
      pf = (PersistentFactory) getService(PersistentFactory.ROLE);
      myUser = pf.create("keel.user");
    }
    catch (ServiceException e)
    {
      throw new UserMgrException(e);
    }
View Full Code Here

  /**
   * @return
   */
  private Persistent getGroupPersistent() throws UserMgrException
  {
    PersistentFactory pf = null;
    Persistent myGroup = null;

    try
    {
      pf = (PersistentFactory) getService(PersistentFactory.ROLE);
      myGroup = pf.create("keel.usergroup");
    }
    catch (ServiceException e)
    {
      throw new UserMgrException(e);
    }
View Full Code Here

  /**
   * @return
   */
  private Persistent getGroupMembersPersistent() throws UserMgrException
  {
    PersistentFactory pf = null;
    Persistent myGroupMembers = null;

    try
    {
      pf = (PersistentFactory) getService(PersistentFactory.ROLE);
      myGroupMembers = pf.create("keel.groupmembers");
    }
    catch (ServiceException e)
    {
      throw new UserMgrException(e);
    }
View Full Code Here

   * @param req The model request.
   * @throws ModelException In case of a business failure.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    PersistentFactory persistentFactory = (PersistentFactory) req.getService(PersistentFactory.ROLE, req
            .getDomain());

    ModelResponse res = req.createResponse();

    DataSourceComponent dataSourceComponent = (DataSourceComponent) req.getService(DataSourceComponent.ROLE,
            "keel-dbpool");

    List<Configuration> moduleConfigs = de.iritgo.aktera.base.module.ModuleInfo
            .moduleConfigsSortedByDependency(req);

    try
    {
      Connection connection = null;

      try
      {
        connection = dataSourceComponent.getConnection();

        for (Configuration moduleConfig : moduleConfigs)
        {
          String moduleId = moduleConfig.getAttribute("id", "unkown");
          String createHandlerClassName = moduleConfig.getChild("create").getAttribute("class", null);

          if (createHandlerClassName != null)
          {
            try
            {
              System.out.println("CreateDatabase: Creating tables of module '" + moduleId
                      + "' with handler '" + createHandlerClassName + "'");

              Class klass = Class.forName(createHandlerClassName);

              if (klass != null)
              {
                CreateHandler createHandler = (CreateHandler) klass.newInstance();
                createHandler.setConnection(connection);
                createHandler.createTables(req, persistentFactory, connection, log);
              }
              else
              {
                log
                        .error("CreateDatabase: Unable to find create handler for module '"
                                + moduleId + "'");
              }
            }
            catch (ClassNotFoundException x)
            {
              log.error("CreateDatabase: Unable call create handler for module '" + moduleId + "': " + x);
            }
            catch (Exception x)
            {
              res.addOutput("databaseError", x.getMessage());
              res.addOutput("databaseErrorStackTrace", StringTools.stackTraceToString(x).replaceAll("\n",
                      "<br>"));

              return res;
            }
          }
        }
      }
      catch (SQLException x)
      {
        log.error("Unable to create database connection", x);
      }
      finally
      {
        try
        {
          connection.close();
        }
        catch (SQLException x)
        {
        }
      }

      connection = null;

      try
      {
        connection = dataSourceComponent.getConnection();

        for (Configuration moduleConfig : moduleConfigs)
        {
          String moduleId = moduleConfig.getAttribute("id", "unkown");
          String createHandlerClassName = moduleConfig.getChild("create").getAttribute("class", null);

          if (createHandlerClassName != null)
          {
            try
            {
              System.out.println("CreateDatabase: Creating data of module '" + moduleId
                      + "' with handler '" + createHandlerClassName + "'");

              Class klass = Class.forName(createHandlerClassName);

              if (klass != null)
              {
                CreateHandler createHandler = (CreateHandler) klass.newInstance();
                createHandler.setConnection(connection);
                createHandler.createData(persistentFactory, connection, log, req);
              }
              else
              {
                log
                        .error("CreateDatabase: Unable to find create handler for module '"
                                + moduleId + "'");
              }
            }
            catch (ClassNotFoundException x)
            {
              log.error("CreateDatabase: Unable call create handler for module '" + moduleId + "': " + x);
            }
            catch (Exception x)
            {
              res.addOutput("databaseError", x.getMessage());
              res.addOutput("databaseErrorStackTrace", StringTools.stackTraceToString(x).replaceAll("\n",
                      "<br>"));

              return res;
            }
          }
        }
      }
      catch (SQLException x)
      {
        log.error("Unable to create database connection", x);
      }
      finally
      {
        try
        {
          connection.close();
        }
        catch (SQLException x)
        {
        }
      }

      try
      {
        for (Configuration moduleConfig : moduleConfigs)
        {
          Persistent version = persistentFactory.create("aktera.Version");

          version.setField("type", "M");
          version.setField("name", moduleConfig.getAttribute("id", "unkown"));
          version.setField("version", moduleConfig.getChild("version").getValue("0.0.0"));
          version.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }

      try
      {
        Model appInfo = (Model) req.getService(Model.ROLE, "aktera.app-info");

        Configuration[] appConfigs = appInfo.getConfiguration().getChildren("app");

        for (int i = 0; i < appConfigs.length; ++i)
        {
          Configuration appConfig = appConfigs[i];

          Persistent version = persistentFactory.create("aktera.Version");

          version.setField("type", "A");
          version.setField("name", appConfig.getAttribute("id", "unkown"));
          version.setField("version", appConfig.getChild("version").getValue("0.0.0"));
          version.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }

      try
      {
        Persistent config = persistentFactory.create("aktera.SystemConfig");

        config.setField("category", "system");
        config.setField("name", "databaseCreated");
        config.setField("type", "B");
        config.setField("value", "true");
View Full Code Here

   * @param req The model request.
   * @throws ModelException In case of a business failure.
   */
  public ModelResponse execute(ModelRequest req) throws ModelException
  {
    PersistentFactory persistentManager = (PersistentFactory) req.getService(PersistentFactory.ROLE, req
            .getDomain());

    SystemConfigManager systemConfigManager = (SystemConfigManager) req.getSpringBean(SystemConfigManager.ID);

    ModelResponse res = req.createResponse();

    Configuration config = getConfiguration();

    String layoutName = "iritgo";

    try
    {
      layoutName = systemConfigManager.getString("gui", "layout");
    }
    catch (Exception x)
    {
    }

    String themeName = "iritgong";

    try
    {
      themeName = (String) systemConfigManager.get("gui", "defaultTheme");

      if (themeName == null && config != null)
      {
        themeName = config.getChild("theme-name").getValue("root");
      }

      if (themeName == null)
      {
        themeName = "iritgong";
      }

      if (! systemConfigManager.getBool("gui", "disableThemeChange"))
      {
        Preferences preferences = (Preferences) UserTools.getUserEnvObject(req, "sessionPreferences");

        if (preferences != null)
        {
          themeName = preferences.getTheme();

          try
          {
            if (! persistentManager.create("aktera.Preferences").getValidValues("theme").containsKey(
                    themeName))
            {
              themeName = "iritgong";
            }
          }
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.persist.PersistentFactory

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.