1 6 package com.nightlabs.ipanema.person; 7 8 import java.util.Collection ; 9 import java.util.HashMap ; 10 import java.util.Map ; 11 12 import com.nightlabs.ipanema.base.DuplicateKeyException; 13 14 17 25 public class SelectionPersonStructField extends AbstractPersonStructField { 26 27 38 protected Map personStructFieldValues = new HashMap (); 39 40 public Collection getPersonStructFieldValues() { 41 return personStructFieldValues.values(); 42 } 43 44 52 public PersonStructFieldValue getPersonStructFieldValue(String personStructFieldValueID) 53 throws PersonStructFieldValueNotFoundException 54 { 55 PersonStructFieldValue psfv = (PersonStructFieldValue)personStructFieldValues.get(personStructFieldValueID); 56 if (psfv == null) { 57 throw new PersonStructFieldValueNotFoundException("No PersonStructFieldValue with ID \""+personStructFieldValueID+"\" existent in PersonStructField \""+getPersonStructFieldID()+"\" in PersonStructBlock \""+getPersonStructBlockID()+"\"!"); 58 } 59 return psfv; 60 } 61 62 68 public PersonStructFieldValue newPersonStructFieldValue(String personStructFieldValueID) { 69 PersonStructFieldValue psfv = new PersonStructFieldValue(this, personStructFieldValueID); 70 personStructFieldValues.put(personStructFieldValueID, psfv); 71 return psfv; 72 } 73 74 78 public AbstractPersonDataField addNewDataFieldInstance(PersonDataBlock dataBlock) { 79 SelectionPersonDataField newInstance = new SelectionPersonDataField(dataBlock,this); 80 try { 81 dataBlock.addPersonDataField(newInstance); 82 } catch (DuplicateKeyException e) { 83 throw new RuntimeException ("Caught DuplicateKeyException when adding new instance of SelectionPersonDataField ("+newInstance.getPersonStructBlockOrganisationID()+", "+newInstance.getPersonStructBlockID()+") to dataBlock ("+dataBlock.getPersonStructBlockOrganisationID()+", "+dataBlock.getOrganisationID()); 84 } 85 return newInstance; 86 } 87 88 } 89 | Popular Tags |