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.


   and not fetched from the database at all. This style should be used with care.  
  */
  private static Map<Id, Code> getRatings() throws DAOException {
    Map<Id, Code> result = new LinkedHashMap<Id, Code>();
    for(int idx=0; idx <= 10; ++idx ){
      Id id  = new Id(new Integer(idx).toString());
      Code code = null;
      try {
        code = new Code(id, SafeText.from(id.toString()));
      }
      catch (ModelCtorException ex){
        throw new DAOException("Cannot build Code in expected manner.",ex);     
      }
      result.put(id, code);
View Full Code Here


   a {@link DuplicateException} is thrown.
  
   @return the autogenerated database id.
  */
  Id add(Resto aResto) throws DAOException, DuplicateException {
    Id result = Db.add(ADD_RESTO, baseParamsFrom(aResto));
    return result;
  }
View Full Code Here

  }

  // PRIVATE //

  private void testCtorSuccess(String aId, String aName, Boolean aIsActive, String aDisposition) {
    Id id = (aId != null ? Id.from(aId) : null);
    SafeText name = (aName != null ? new SafeText(aName) : null);
    Id disposition = (aDisposition != null ? Id.from(aDisposition) : null);
    try {
      Member member = new Member(id, name, aIsActive, disposition);
    }
    catch (ModelCtorException ex) {
      fail("Failed to construct Member.");
View Full Code Here

      fail("Failed to construct Member.");
    }
  }

  private void testCtorFailure(String aId, String aName, Boolean aIsActive, String aDisposition) {
    Id id = (aId != null ? Id.from(aId) : null);
    SafeText name = (aName != null ? new SafeText(aName) : null);
    Id disposition = (aDisposition != null ? Id.from(aDisposition) : null);
    try {
      Member member = new Member(id, name, aIsActive, disposition);
      fail("Unexpectedly succeeded in constructing Member.");
    }
    catch (ModelCtorException ex) {
View Full Code Here

      for(Member existingMember:  fMembers.values()){
        if ( existingMember.getName().equals(aMember.getName())){
          throw new DuplicateException("Duplicate name: " + Util.quote(aMember.getName()), new Throwable());
        }
      }
      Id id = getNewId();
      //need to attach the id to the member in two ways here
      Member member = getMemberWithId(aMember, id);
      fMembers.put(id, member);
      return id;
    }
View Full Code Here

  */
  private BaseText getParent() {
    if( fParent == null){
      BaseTextDAO dao = new BaseTextDAO();
      //this req param needs to always be present
      Id baseTextId = getIdParam(BASE_TEXT_ID);
      fLogger.fine("Fetching BaseText for " + Util.quote(baseTextId));
      try {
        fParent = dao.fetch(baseTextId);
      }
      catch(DAOException ex){
View Full Code Here

  //PRIVATE//
 
  private void testForSuccess(MemberDAO aMemberDAO) throws DAOException, ModelCtorException {
    //add
    Member memberOne = new Member(null, new SafeText("Bob Smithers"), Boolean.TRUE, Id.from("4") );
    Id idOne = aMemberDAO.add(memberOne);
   
    //fetch
    Member memberOneFetched = aMemberDAO.fetch(idOne);
    assertNotNull(memberOneFetched);
    assertTrue(memberOneFetched.equals(memberOne));
View Full Code Here

 
  private void testFakeForFailures(MemberDAO aMemberDAO) throws ModelCtorException, DAOException {
    //add
    Member memberOne = new Member(null, new SafeText("Bob Smithers"), Boolean.TRUE, Id.from("4") );
    try {
      Id id = aMemberDAO.add(memberOne);
      fail("Should have failed.");
    }
    catch(DuplicateException ex){
      //should happen - do nothing
    }
View Full Code Here

  private GentlemanCaller VISIT_B;

  private void testEqualsFor(Visit aVisit, String aId, String aRestoId, Date aDate, String aComment) {
    Visit testVisit = null;
    Id visitId = (aId != null ? Id.from(aId) : null);
    try {
      testVisit = new Visit(visitId, Id.from(aRestoId), aDate, new SafeText(aComment));
    }
    catch (ModelCtorException ex) {
      throw new RuntimeException(ex);
View Full Code Here

  }

  private void testNotEqualsFor(Visit aVisit, String aId, String aRestoId, Date aDate,
  String aComment) {
    Visit testVisit = null;
    Id visitId = (aId != null ? Id.from(aId) : null);
    try {
      testVisit = new Visit(visitId, Id.from(aRestoId), aDate, new SafeText(aComment));
    }
    catch (ModelCtorException ex) {
      throw new RuntimeException(ex);
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.