Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.PersistenceException


   */
  public Persistent create(String name) throws PersistenceException
  {
    if (! isConfigured())
    {
      throw new PersistenceException("Factory not configured!");
    }

    DefaultPersistent newPersistent = null;

    if (name.indexOf(".") < 0)
    {
      throw new PersistenceException("Name of Persistent must be of the form 'schema.name'" + ":'" + name + "'");
    }

    try
    {
      PersistentMetaData pmd = getMetaData(name);

      /**
       * If this persistent is not instantiated using a custom class...
       */
      if (pmd.getClassName() == null)
      {
        if (pmd.isRowSecurable())
        {
          newPersistent = new RowSecurablePersistent();
        }
        else
        {
          newPersistent = new DefaultPersistent();
        }

        /* We pass our persistent's the same log as the factory... */
        newPersistent.setLogger(log);

        /* And a reference back to their factory, so they can */
        /* access getService, etc */
        newPersistent.setFactory(this);
        newPersistent.setMetaData(pmd);
        newPersistent.setAuthorizationManager(pmd.getAuthManager());

        /* If auth manager bypass is allowed at all for this persistent, */
        /* hand it the default bypass manager */
        if (pmd.isAuthManagerBypassAllowed())
        {
          newPersistent.setBypassAuthorizationManager(getByPassAuthManager());
        }

        return newPersistent;
      }
      else
      {
        Class c = Class.forName(pmd.getClassName());
        Object o = c.newInstance();

        /* If the class we instantiated extends Persistent... */
        if (o instanceof Persistent)
        {
          Persistent p = (Persistent) c.newInstance();

          p.setMetaData(pmd);

          return p;
        }
        else
        {
          /* If it does not, then "wrap" it in a persistent */
          DefaultPersistent np = null;

          if (pmd.isRowSecurable())
          {
            np = new RowSecurablePersistent();
          }
          else
          {
            np = new DefaultPersistent();
          }

          /* We pass our persistent's the same log as the factory... */
          np.setLogger(log);

          /* And a reference back to their factory, so they can */
          /* access getService, etc */
          np.setFactory(this);
          np.setMetaData(pmd);
          np.setAuthorizationManager(pmd.getAuthManager());

          /* If auth manager bypass is allowed at all for this persistent, */
          /* hand it the default bypass manager */
          if (pmd.isAuthManagerBypassAllowed())
          {
            np.setBypassAuthorizationManager(getByPassAuthManager());
          }

          np.setBean(o);

          return np;
        }
      }
    }
    catch (Exception ce)
    {
      throw new PersistenceException(ce);
    }
  }
View Full Code Here


      /* Get the appropriate schema object */
      Configuration oneSchema = (Configuration) schemas.get(schema);

      if (oneSchema == null)
      {
        throw new PersistenceException("No such schema '" + schema + "' defined in Persistent Factory '"
                + getName() + "'");
      }

      Configuration[] eachPersistent = oneSchema.getChildren();

      for (int i = 0; i < eachPersistent.length; i++)
      {
        Configuration onePersistent = eachPersistent[i];
        String persistentName = onePersistent.getAttribute("name");
        PersistentMetaData pmd = getMetaData(schema + "." + persistentName);

        databaseType.createTable(pmd, dataSource);

        /* Now look for default data */
        Configuration[] children = eachPersistent[i].getChildren();
        Configuration oneChild = null;

        for (int j = 0; j < children.length; j++)
        {
          oneChild = children[j];

          if (oneChild.getName().equals("default-data"))
          {
            /* Create the default data for each record */
            createRecords(oneChild, schema + "." + persistentName, pmd);
          }
        }
      }
    }
    catch (Exception ce)
    {
      throw new PersistenceException(ce);
    }
    finally
    {
      if (securityBypass)
      {
View Full Code Here

      /* Get the appropriate schema object */
      Configuration oneSchema = (Configuration) schemas.get(schema);

      if (oneSchema == null)
      {
        throw new PersistenceException("No such schema '" + schema + "' defined in Persistent Factory '"
                + getName() + "'");
      }

      Configuration[] eachPersistent = oneSchema.getChildren();

      for (int i = 0; i < eachPersistent.length; i++)
      {
        Configuration onePersistent = eachPersistent[i];
        String persistentName = onePersistent.getAttribute("name");
        PersistentMetaData pmd = getMetaData(schema + "." + persistentName);

        databaseType.createIndices(pmd, dataSource);
      }
    }
    catch (Exception ce)
    {
      throw new PersistenceException(ce);
    }
  }
View Full Code Here

      /* Get the appropriate schema object */
      Configuration oneSchema = (Configuration) schemas.get(schema);

      if (oneSchema == null)
      {
        throw new PersistenceException("No such schema '" + schema + "' defined in Persistent Factory '"
                + getName() + "'");
      }

      Configuration[] eachPersistent = oneSchema.getChildren();

      for (int i = 0; i < eachPersistent.length; i++)
      {
        Configuration onePersistent = eachPersistent[i];
        String persistentName = onePersistent.getAttribute("name");
        PersistentMetaData pmd = getMetaData(schema + "." + persistentName);

        databaseType.dropIndices(pmd, dataSource);
      }
    }
    catch (Exception ce)
    {
      throw new PersistenceException(ce);
    }
  }
View Full Code Here

        myConnection.setAutoCommit(false);
      }
    }
    catch (SQLException se)
    {
      throw new PersistenceException(se);
    }
  }
View Full Code Here

      myConnection.close();
    }
    catch (SQLException se)
    {
      throw new PersistenceException(se);
    }
  }
View Full Code Here

      myConnection.close();
    }
    catch (SQLException se)
    {
      throw new PersistenceException(se);
    }
  }
View Full Code Here

   */
  public Connection getConnection() throws PersistenceException
  {
    if (myConnection == null)
    {
      throw new PersistenceException("Transaction not begun");
    }

    return myConnection;
  }
View Full Code Here

          set(oneFieldName, pe.getFieldString(oneFieldName));

          break;

        default:
          throw new PersistenceException("Invalid JDBC Data Type.");
      }
    }
  }
View Full Code Here

                + "\t" + tm.getAutoIncrement() + "\t" + tm.getLocalTypeName() + "\t" + tm.getMinScale()
                + "\t" + tm.getMaxScale() + "\t" + tm.getNumPrecRadix());
      }

      log.error("----------------");
      throw new PersistenceException("Type '" + type + "' is not mapped to any valid type");
    }

    return tm.getTypeName();
  }
View Full Code Here

TOP

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

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.