Package hirondelle.web4j.model

Examples of hirondelle.web4j.model.Id

The underlying database column may be modeled as either text or as a number. If the underlying column is of a numeric type, however, then a Data Access Object will need to pass Id parameters to {@link hirondelle.web4j.database.Db} using {@link #asInteger} or {@link #asLong}.

Design Note :
This class is final, immutable, {@link Serializable}, and {@link Comparable}, in imitation of the other building block classes such as {@link String}, {@link Integer}, and so on.


  /** Check user input can build a {@link Preferences} object. */
  protected void validateUserInput() throws AppException {
    if( isLoggedIn()){
      try {
        Id  userId = getUserId();
        ModelFromRequest builder = new ModelFromRequest(getRequestParser());
        fPreferences = builder.build(Preferences.class, userId, getLoggedInUserName(),  SCREEN_NAME, LOCALE);
      }
      catch (ModelCtorException ex){
        addError(ex);
View Full Code Here


    else if ( aObject instanceof Code ) {
      Code code = (Code)aObject;
      result = code.getId().getRawString();
    }
    else if ( aObject instanceof Id ) {
      Id id = (Id)aObject;
      result = id.getRawString();
    }
    else if ( aObject instanceof SafeText ) {
      //The Populate tag will safely escape all such text data.
      //To avoid double escaping, the raw form is returned.
      SafeText safeText = (SafeText)aObject;
View Full Code Here

   @param aSqlId identifies the underlying SQL statement.
   @param aParams <a href="#Parameters">parameters</a> for the SQL statement.
  */
  public static Id add(SqlId aSqlId, Object... aParams) throws DAOException, DuplicateException  {
    SqlEditor add = SqlEditor.forSingleOp(aSqlId, aParams);
    return new Id(add.addRecord());
  }
View Full Code Here

      //but it safely avoids double escaping at the end of this method
      SafeText text = (SafeText) aObject;
      result = text.getRawString();
    }
    else if (aObject instanceof Id){
      Id id = (Id) aObject;
      result = id.getRawString();
    }
    else if (aObject instanceof Code){
      Code code = (Code) aObject;
      result = code.getText().getRawString();
    }
View Full Code Here

    fLogger.finest("Parent constructor arg values, minus children : " + ctorArgsMinusChildren);
   
    //build a child for each collection of rows that belongs to the given parent
    //identify new parents using changes in FIRST col only
    Constructor<?> childCtor = ModelCtorUtil.getConstructor(fChildClass, fNumColsForChildList);
    Id parentId = new Id(aRow.getString(FIRST_COLUMN));
    fLogger.finest("Building Child List for Parent Id: " + parentId);
    Id currentId = null;
    List<Object> childList = new ArrayList<Object>();
    do {
      addChildToList(childCtor, childList, aRow);
      aRow.next();
      if ( ! aRow.isAfterLast() ){
        currentId = new Id(aRow.getString(FIRST_COLUMN));
        fLogger.finest("Updated current id: " + currentId);
      }
    }
    while( !aRow.isAfterLast() && currentId.equals(parentId) );
    //back up to PREVIOUS row, in preparation for next section/full model object, if any.
    aRow.previous();
    return buildFinalModelObjectWithChildList(parentCtor, ctorArgsMinusChildren, childList);
  }
View Full Code Here

   @param aSqlId identifies the underlying SQL statement.
   @param aParams <a href="#Parameters">parameters</a> for the SQL statement.
  */
  public static Id add(Connection aConnection, SqlId aSqlId, Object... aParams) throws DAOException, DuplicateException  {
    SqlEditor add = SqlEditor.forTx(aSqlId, aConnection, aParams);
    return new Id(add.addRecord());
  }
View Full Code Here

      long value = aRow.getLong(aColumnIdx);
      result = aRow.wasNull() ? null : new Long(value);
    }
    else if (aSupportedTargetType == Id.class){
      String value = aRow.getString(aColumnIdx);
      result = aRow.wasNull() ? null : new Id(value);
    }
    else if (aSupportedTargetType == Locale.class){
      String value = aRow.getString(aColumnIdx);
      result = value == null ? null : Util.buildLocale(value);
    }
View Full Code Here

    return result;
  }
   
  /** Return a single-valued request parameter as an {@link Id}.  */
  public final Id toId(RequestParameter aReqParam) {
    Id result = null;
    try {
      result = toSupportedObject(aReqParam, Id.class);
    }
    catch(ModelCtorException ex){
      changeToRuntimeException(ex);
View Full Code Here

   <P><style class='highlight'>This internal database identifier should never be served to the client, since that
   would be a grave security risk.</style> The user id should only be used in server-side code, and never
   presented to the user in a JSP.
  */
  protected final Id getUserId(){
    Id result = (Id) getFromSession(USER_ID);
    return result;
  }
View Full Code Here

        Long paramVal = (Long)param;
        aStatement.setLong(idx, paramVal.longValue());
      }
      else if (param instanceof Id) {
        fLogger.finest("Param" + idx + ": Id");
        Id paramId = (Id)param;
        aStatement.setString(idx, paramId.getRawString());
      }
      else if (param instanceof SafeText) {
        fLogger.finest("Param" + idx + ": SafeText");
        SafeText paramText = (SafeText)param;
        aStatement.setString(idx, paramText.getRawString());
View Full Code Here

TOP

Related Classes of hirondelle.web4j.model.Id

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.