Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.PersistenceException


  {
    PersistentField oneField = (PersistentField) allFields.get(fieldName);

    if (oneField == null)
    {
      throw new PersistenceException("No such field '" + fieldName + "'" + " in object '" + getName() + "'");
    }

    String listName = oneField.getListNameForValidValues();

    if (listName == null)
    {
      throw new PersistenceException("There is no listNameForValidValues " + "specified for field   '" + fieldName
              + "' in object '" + getName() + "'.");
    }

    Persistent listHeader = getFactory().create("keel.KeelListHeader");

    listHeader.setField("ListName", listName);

    if (! listHeader.find())
    {
      throw new PersistenceException("There is no list name of '" + listName
              + "' defined in KeelListHeader, as specified for field   '" + fieldName + "' in object '"
              + getName() + "'.");
    }

    boolean useSortOrder = false;
View Full Code Here


      return generator;
    }
    catch (ServiceException ce)
    {
      throw new PersistenceException("Unable to create id generator service for field '" + fieldName
              + "' in persistent '" + getSchemaName() + "." + getName() + "' using hint '" + hint
              + "' - have you configured an IdGenerator called '" + hint + "'?", ce);
    }
  }
View Full Code Here

    public void populate(String myName, String myDBFieldName, short myType, String dType, int mySize,
            int newPrecision, boolean myAllowNull, String myDescrip) throws PersistenceException
    {
      if (logger == null)
      {
        throw new PersistenceException("Log not set");
      }

      //       if (myDBFieldName.length() > 18) {
      //         logger.warn(
      //           "Field name '"
View Full Code Here

      createIndices(pmd, myConnection, true);
    }
    catch (Exception e)
    {
      log.error("Error building create statement", e);
      throw new PersistenceException("Unable to build/execute create statement '" + createStatement.toString()
              + "' for table '" + pmd.getTableName() + "'", e);
    }
    finally
    {
      try
      {
        if (myConnection != null)
        {
          myConnection.close();
        }
      }
      catch (SQLException se)
      {
        throw new PersistenceException("Unable to close/release connection", se);
      }
    }
  }
View Full Code Here

        }
      }
    }
    catch (SQLException se)
    {
      throw new PersistenceException(se);
    }
    finally
    {
      try
      {
        if (myConnection != null)
        {
          myConnection.close();
        }
      }
      catch (SQLException se)
      {
        throw new PersistenceException(se);
      }
    }
  } // setDataSource
View Full Code Here

    currentErrors.put(fieldName, t);
  }

  protected final void addError(String fieldName, String errorMsg)
  {
    currentErrors.put(fieldName, new PersistenceException(errorMsg));
  }
View Full Code Here

    if (! myMetaData.allowsNull(fieldName))
    {
      if (fieldValue == null)
      {
        throw new PersistenceException("$keelNullNotAllowed|" + myMetaData.getTableName() + "."
                + myMetaData.getDescription(fieldName));
      }
      else if (fieldValue.toString().equals(""))
      {
        throw new PersistenceException("$keelNullNotAllowed|" + myMetaData.getTableName() + "."
                + myMetaData.getDescription(fieldName));
      }
    }
    else
    { /* It's null and it's allowed to be, so do no further checks */

      if (fieldValue == null)
      {
        return;
      }
    }

    Pattern mask = myMetaData.getPattern(fieldName);

    if (mask != null)
    {
      if (! patternMatcher.matches(fieldValue.toString(), mask))
      {
        throw new PersistenceException("$keelFieldNotMatch|" + fieldName + "|" + mask.getPattern());
      }
    }

    /*
     * For multi-valued fields, the value specified must be one of the
     * valid values Note: I have changed this behavior slightly from
     * previous versions. If a field has been marked as "allowsNull", it
     * should pass the check below, even if the field has also been marked
     * as "multiValued". In other words, a mutlivalued, allowsnull field
     * should pass the checkField method if it has a null value. - Adam
     */
    if (myMetaData.isMultiValued(fieldName) && (! fieldValue.equals("")))
    {
      //Added this line to fix object comparison problems - ACR
      String stringFieldValue = fieldValue.toString();
      Map values = getValidValues(fieldName);

      if (values == null)
      {
        throw new PersistenceException("(" + getName() + ") '" + myMetaData.getDescription(fieldName)
                + "' is set as multi-valued, but there are no defined " + "valid values" + toString());
      }

      Object oneValue = null;

      for (Iterator e = values.keySet().iterator(); e.hasNext();)
      {
        oneValue = (String) e.next();

        //Changed this line to fix object comparison issues. - ACR
        if (stringFieldValue.equals(oneValue))
        {
          return;
        }
      } /* for each valid value */
      throw new PersistenceException("(" + getName() + ") '" + fieldValue + "' is not a valid value for field '"
              + fieldName + "(" + myMetaData.getDescription(fieldName) + ")' " + toString());
    } /* if field is multi-valued */
    if (isDateType(myMetaData.getType(fieldName)))
    {
      String stringDate = fieldValue.toString();

      String format = "yyyy-MM-dd hh:mm:ss";
      String type = myMetaData.getType(fieldName);

      if (type.equalsIgnoreCase("date"))
      {
        format = "yyyy-MM-dd";
      }
      else if (type.equalsIgnoreCase("time"))
      {
        format = "hh:mm:ss";
      }

      //--- quikdraw: This is doing exactly what?
      try
      {
        new SimpleDateFormat(format).parse(stringDate);
      }
      catch (ParseException pe)
      {
        throw new PersistenceException("Value '" + stringDate + "' for field '"
                + myMetaData.getDescription(fieldName) + "' cannot be parsed as a date");
      }
    }
  } /* checkField(String, String) */
 
View Full Code Here

      {
        detailObj = getFactory().create(oneDetRelation.getToPersistent());
      }
      catch (Exception e)
      {
        throw new PersistenceException("Unable to instantiate " + "detail db object '"
                + oneDetRelation.getToPersistent() + "'", e);
      }

      if (currentTransaction != null)
      {
        detailObj.setTransaction(currentTransaction);
      }

      if (! detailObj.allowed(Persistent.DELETE))
      {
        throw new PersistenceException("Delete of '" + oneDetRelation.getToPersistent() + "' not allowed");
      }

      Iterator stkLocal = oneDetRelation.getFromFields().iterator();
      Iterator stkForeign = oneDetRelation.getToFields().iterator();
View Full Code Here

  protected void assertField(String fieldName) throws PersistenceException
  {
    if (! myMetaData.hasField(fieldName))
    {
      throw new PersistenceException("Persistent '" + getName() + "' contains no such field as " + fieldName);
    }
  }
View Full Code Here

        }
      }
    }
    catch (Exception e)
    {
      throw new PersistenceException(e);
    }

    return returnValue;
  } /* getSerializedForm() */
 
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.