Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.PersistenceException


    String convertFormat = new String("");
    String convertFunction = new String("");

    if (! myMetaData.hasField(fieldName))
    {
      throw new PersistenceException("(" + getName() + ") No such field as " + fieldName);
    }

    if (getField(fieldName) == null)
    {
      return null;
    }

    if (getField(fieldName).equals(""))
    {
      return null;
    }

    String myType = myMetaData.getType(fieldName);

    if (myType.equalsIgnoreCase("date"))
    {
      convertFormat = myMetaData.getDatabaseType().getDateUpdateFormat();
      convertFunction = myMetaData.getDatabaseType().getDateUpdateFunction();
    }
    else if (myType.equalsIgnoreCase("datetime") || myType.equalsIgnoreCase("timestamp"))
    {
      convertFormat = myMetaData.getDatabaseType().getDateTimeUpdateFormat();
      convertFunction = myMetaData.getDatabaseType().getDateTimeUpdateFunction();
    }
    else if (myType.equalsIgnoreCase("time"))
    {
      convertFormat = myMetaData.getDatabaseType().getTimeUpdateFormat();
      convertFunction = myMetaData.getDatabaseType().getTimeUpdateFunction();
    }
    else
    {
      throw new PersistenceException("Field '" + fieldName + "' is not a date, datetime or time - it is a "
              + myType + ", which cannot be formatted " + "as a Date/Time type");
    }

    convertFormat = SuperString.notNull(convertFormat);
    convertFunction = SuperString.notNull(convertFunction);

    /* If no format was specified, don't change the existing field */
    if (convertFormat.equals(""))
    {
      if (! convertFunction.equals(""))
      {
        return SuperString.replace(convertFunction, "%s", "'" + getField(fieldName) + "'");
      }
      else
      {
        return "'" + getField(fieldName) + "'";
      }
    }

    String returnValue = null;

    SimpleDateFormat formatter = new SimpleDateFormat(convertFormat);

    returnValue = "'" + formatter.format(originalDate) + "'";

    if (returnValue == null)
    {
      throw new PersistenceException("(" + getName() + ") Unable to format date value from field " + fieldName
              + ", value was " + getField(fieldName));
    }

    if (! convertFunction.equals(""))
    {
View Full Code Here


    {
      strVal = o.toString();

      if (strVal == null)
      {
        throw new PersistenceException("(" + getName() + ") Unable to get int value from field " + fieldName
                + ", value was '" + strVal + "'");
      }

      return Long.parseLong(strVal);
    }
    catch (NumberFormatException ex)
    {
      throw new PersistenceException("(" + getName() + ") Unable to parse an integer value from field "
              + fieldName + " which contained '" + strVal, ex);
    }
  } /* getFieldLong(String) */
 
View Full Code Here

        myHelper = (Helper) c.newInstance();
      }
      catch (Exception e)
      {
        throw new PersistenceException(e);
      }
    }

    return myHelper;
  }
View Full Code Here

      createBean();
    }

    if (myBean == null)
    {
      throw new PersistenceException("No bean class defined for " + getName());
    }

    String oneFieldName = null;

    for (Iterator i = myMetaData.getFieldNames().iterator(); i.hasNext();)
View Full Code Here

    {
      myBypassAuthManager = bypassAm;
    }
    else
    {
      throw new PersistenceException("Bypass of AuthorizationManager not allowed for " + getName());
    }
  }
View Full Code Here

   */
  public synchronized Map getValidValues(String fieldName) throws PersistenceException
  {
    if (! myMetaData.isMultiValued(fieldName))
    {
      throw new PersistenceException("Field '" + fieldName + "' in object '" + getName()
              + "' is not specified as multi-valued, so you cannot "
              + "call getValidValues for this field");
    }

    //First look for static values. These take precedence.
View Full Code Here

      return new Date(myDate.getTime());
    }
    catch (Exception de)
    {
      throw new PersistenceException("Could not extract a date value from " + o.getClass().getName() + " '"
              + o.toString() + "' for field '" + fieldName + "'", de);
    }
  } /* getFieldDate(String) */
 
View Full Code Here

   */
  public boolean getFieldBoolean(String fieldName) throws PersistenceException
  {
    if (! myMetaData.hasField(fieldName))
    {
      throw new PersistenceException("(" + getName() + ") No such field as " + fieldName);
    }

    Object o = getFieldData(fieldName);

    if (o == null)
View Full Code Here

      case java.sql.Types.SMALLINT:
      case java.sql.Types.TINYINT:

        if (! SuperString.isNumber(value))
        {
          throw new PersistenceException("Value '" + value + "' is not a number");
        }

        break;

      case java.sql.Types.BIT:
      case java.sql.Types.BOOLEAN:

        try
        {
          SuperString.assertBoolean(value, "Value '" + value + "' is not boolean");
        }
        catch (IllegalArgumentException ie)
        {
          throw new PersistenceException(ie.getMessage());
        }

        break;

      case java.sql.Types.DATE:
      case java.sql.Types.TIME:
      case java.sql.Types.TIMESTAMP:

        try
        {
          //                     SuperString ss = new SuperString(value);
          SuperString ss = new SuperString(getFieldDate(fieldName).toString());

          ss.toDate();
        }
        catch (IllegalArgumentException ie)
        {
          throw new PersistenceException(ie.getMessage());
        }

        break;

      case java.sql.Types.DECIMAL:
      case java.sql.Types.DOUBLE:
      case java.sql.Types.FLOAT:
      case java.sql.Types.NUMERIC:
      case java.sql.Types.REAL:

        if (! SuperString.isRealNumber(value))
        {
          throw new PersistenceException("Value '" + value + "' is not a number");
        }

        break;

      default:
View Full Code Here

    {
      Configuration mySchema = (Configuration) schemas.get(schemaName);

      if (mySchema == null)
      {
        throw new PersistenceException("No such schema '" + schemaName + "' defined for PersistentFactory '"
                + getName() + "'");
      }

      Configuration[] eachTable = mySchema.getChildren();

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

        if (oneTable.getName().equals("persistent"))
        {
          returnSet.add(oneTable.getAttribute("name"));
        }
      }

      return returnSet;
    }
    catch (ConfigurationException ce)
    {
      throw new PersistenceException(ce);
    }
  }
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.