1 4 package com.nightlabs.ipanema.accounting; 5 6 import java.io.Serializable ; 7 8 import javax.jdo.JDOObjectNotFoundException; 9 import javax.jdo.PersistenceManager; 10 11 import com.nightlabs.ipanema.accounting.id.PriceFragmentTypeID; 12 import com.nightlabs.ipanema.organisation.Organisation; 13 14 31 public class PriceFragmentType 32 implements Serializable 33 { 34 38 private String organisationID; 39 40 44 private String priceFragmentTypeID; 45 46 protected PriceFragmentType() { } 47 48 public PriceFragmentType(String organisationID, String priceFragmentTypeID) 49 { 50 this.organisationID = organisationID; 51 this.priceFragmentTypeID = priceFragmentTypeID; 52 } 53 56 public String getOrganisationID() 57 { 58 return organisationID; 59 } 60 63 public String getPriceFragmentTypeID() 64 { 65 return priceFragmentTypeID; 66 } 67 public String getPrimaryKey() 68 { 69 return organisationID + '/' + priceFragmentTypeID; 70 } 71 public static String getPrimaryKey(String organisationID, String priceFragmentTypeID) 72 { 73 return organisationID + '/' + priceFragmentTypeID; 74 } 75 76 84 public static final String TOTAL_PRICEFRAGMENTTYPEID = "_Total_"; 85 86 91 public static PriceFragmentType getTotalPriceFragmentType(PersistenceManager pm) 92 { 93 pm.getExtent(PriceFragmentType.class); 94 PriceFragmentType priceFragmentType; 95 try { 96 priceFragmentType = (PriceFragmentType) pm.getObjectById(PriceFragmentTypeID.create( 97 Organisation.ROOT_ORGANISATIONID, PriceFragmentType.TOTAL_PRICEFRAGMENTTYPEID)); 98 } catch (JDOObjectNotFoundException x) { 99 priceFragmentType = new PriceFragmentType(Organisation.ROOT_ORGANISATIONID, PriceFragmentType.TOTAL_PRICEFRAGMENTTYPEID); 100 pm.makePersistent(priceFragmentType); 101 } 102 return priceFragmentType; 103 } 104 } 105 | Popular Tags |